Skip to content

Commit 5067e4c

Browse files
committed
Codex: sync local edits in adk-python
1 parent 400cee8 commit 5067e4c

44 files changed

Lines changed: 24151 additions & 23260 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

contributing/samples/agent_registry_agent/agent.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,19 @@
3333
print(f"Listing agents in {project_id}/{location}...")
3434
agents = registry.list_agents()
3535
for agent in agents.get("agents", []):
36-
print(f"- Agent: {agent.get('displayName')} ({agent.get('name')})")
36+
print(f"- Agent: {agent.get('displayName')} ({agent.get('name')})")
3737

3838
print(f"\nListing MCP servers in {project_id}/{location}...")
3939
mcp_servers = registry.list_mcp_servers()
4040
for server in mcp_servers.get("mcpServers", []):
41-
print(f"- MCP Server: {server.get('displayName')} ({server.get('name')})")
41+
print(f"- MCP Server: {server.get('displayName')} ({server.get('name')})")
4242

4343
print(f"\nListing endpoints in {project_id}/{location}...")
4444
endpoints = registry.list_endpoints()
4545
for endpoint in endpoints.get("endpoints", []):
46-
print(f"- Endpoint: {endpoint.get('displayName')} ({endpoint.get('name')})")
46+
print(
47+
f"- Endpoint: {endpoint.get('displayName')} ({endpoint.get('name')})"
48+
)
4749

4850
# Example of using a specific agent or MCP server from the registry:
4951
# (Note: These names should be full resource names as returned by list methods)

contributing/samples/live_bidi_streaming_parallel_tools_agent/agent.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717

1818

1919
def turn_on_lights():
20-
"""Turn on the lights."""
21-
print("turn_on_lights")
22-
return {"status": "OK"}
20+
"""Turn on the lights."""
21+
print("turn_on_lights")
22+
return {"status": "OK"}
2323

2424

2525
def turn_on_tv():
26-
"""Turn on the tv."""
27-
print("turn_on_tv")
28-
return {"status": "OK"}
26+
"""Turn on the tv."""
27+
print("turn_on_tv")
28+
return {"status": "OK"}
2929

3030

3131
root_agent = Agent(

contributing/samples/skills_agent/agent.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
import pathlib
1818

1919
from google.adk import Agent
20-
from google.adk.code_executors.unsafe_local_code_executor import UnsafeLocalCodeExecutor
20+
from google.adk.code_executors.unsafe_local_code_executor import (
21+
UnsafeLocalCodeExecutor,
22+
)
2123
from google.adk.skills import load_skill_from_dir
2224
from google.adk.skills import models
2325
from google.adk.tools.base_tool import BaseTool
@@ -26,37 +28,37 @@
2628

2729

2830
class GetTimezoneTool(BaseTool):
29-
"""A tool to get the timezone for a given location."""
31+
"""A tool to get the timezone for a given location."""
3032

31-
def __init__(self):
32-
super().__init__(
33-
name="get_timezone",
34-
description="Returns the timezone for a given location.",
35-
)
33+
def __init__(self):
34+
super().__init__(
35+
name="get_timezone",
36+
description="Returns the timezone for a given location.",
37+
)
3638

37-
def _get_declaration(self) -> types.FunctionDeclaration | None:
38-
return types.FunctionDeclaration(
39-
name=self.name,
40-
description=self.description,
41-
parameters_json_schema={
42-
"type": "object",
43-
"properties": {
44-
"location": {
45-
"type": "string",
46-
"description": "The location to get the timezone for.",
39+
def _get_declaration(self) -> types.FunctionDeclaration | None:
40+
return types.FunctionDeclaration(
41+
name=self.name,
42+
description=self.description,
43+
parameters_json_schema={
44+
"type": "object",
45+
"properties": {
46+
"location": {
47+
"type": "string",
48+
"description": "The location to get the timezone for.",
49+
},
4750
},
51+
"required": ["location"],
4852
},
49-
"required": ["location"],
50-
},
51-
)
53+
)
5254

53-
async def run_async(self, *, args: dict, tool_context) -> str:
54-
return f"The timezone for {args['location']} is UTC+00:00."
55+
async def run_async(self, *, args: dict, tool_context) -> str:
56+
return f"The timezone for {args['location']} is UTC+00:00."
5557

5658

5759
def get_wind_speed(location: str) -> str:
58-
"""Returns the current wind speed for a given location."""
59-
return f"The wind speed in {location} is 10 mph."
60+
"""Returns the current wind speed for a given location."""
61+
return f"The wind speed in {location} is 10 mph."
6062

6163

6264
greeting_skill = models.Skill(

src/google/adk/a2a/agent/config.py

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -43,82 +43,82 @@
4343

4444

4545
class ParametersConfig(BaseModel):
46-
"""Configuration for the parameters passed to the A2A send_message request."""
46+
"""Configuration for the parameters passed to the A2A send_message request."""
4747

48-
request_metadata: Optional[dict[str, Any]] = None
49-
client_call_context: Optional[ClientCallContext] = None
50-
# TODO: Add support for requested_extension and
51-
# message_send_configuration once they are supported by the A2A client.
52-
#
53-
# requested_extension: Optional[list[str]] = None
54-
# message_send_configuration: Optional[MessageSendConfiguration] = None
48+
request_metadata: Optional[dict[str, Any]] = None
49+
client_call_context: Optional[ClientCallContext] = None
50+
# TODO: Add support for requested_extension and
51+
# message_send_configuration once they are supported by the A2A client.
52+
#
53+
# requested_extension: Optional[list[str]] = None
54+
# message_send_configuration: Optional[MessageSendConfiguration] = None
5555

5656

5757
class RequestInterceptor(BaseModel):
58-
"""Interceptor for A2A requests."""
58+
"""Interceptor for A2A requests."""
5959

60-
before_request: Optional[
61-
Callable[
62-
[InvocationContext, A2AMessage, ParametersConfig],
63-
Awaitable[tuple[Union[A2AMessage, Event], ParametersConfig]],
64-
]
65-
] = None
66-
"""Hook executed before the agent starts processing the request.
60+
before_request: Optional[
61+
Callable[
62+
[InvocationContext, A2AMessage, ParametersConfig],
63+
Awaitable[tuple[Union[A2AMessage, Event], ParametersConfig]],
64+
]
65+
] = None
66+
"""Hook executed before the agent starts processing the request.
6767
6868
Returns an Event if the request should be aborted and the Event
6969
returned to the caller.
7070
"""
7171

72-
after_request: Optional[
73-
Callable[
74-
[InvocationContext, A2AEvent, Event], Awaitable[Union[Event, None]]
75-
]
76-
] = None
77-
"""Hook executed after the agent has processed the request.
72+
after_request: Optional[
73+
Callable[
74+
[InvocationContext, A2AEvent, Event], Awaitable[Union[Event, None]]
75+
]
76+
] = None
77+
"""Hook executed after the agent has processed the request.
7878
7979
Returns None if the event should not be sent to the caller.
8080
"""
8181

8282

8383
class A2aRemoteAgentConfig(BaseModel):
84-
"""Configuration for A2A remote agents."""
85-
86-
# Converts standard A2A Messages into ADK Event.
87-
a2a_message_converter: A2AMessageToEventConverter = (
88-
convert_a2a_message_to_event
89-
)
90-
91-
# Converts an A2A Task into an ADK Event.
92-
a2a_task_converter: A2ATaskToEventConverter = convert_a2a_task_to_event
93-
94-
# Converts A2A TaskStatusUpdateEvents into ADK Event.
95-
a2a_status_update_converter: A2AStatusUpdateToEventConverter = (
96-
convert_a2a_status_update_to_event
97-
)
98-
99-
# Converts A2A TaskArtifactUpdateEvents into ADK Event.
100-
a2a_artifact_update_converter: A2AArtifactUpdateToEventConverter = (
101-
convert_a2a_artifact_update_to_event
102-
)
103-
104-
# A low-level hook that converts individual A2A Message Parts
105-
# into native ADK/GenAI Part objects.
106-
# This is utilized internally by the other converters.
107-
a2a_part_converter: A2APartToGenAIPartConverter = (
108-
convert_a2a_part_to_genai_part
109-
)
110-
111-
request_interceptors: Optional[list[RequestInterceptor]] = None
112-
113-
def __deepcopy__(self, memo):
114-
cls = self.__class__
115-
copied_values = {}
116-
for k, v in self.__dict__.items():
117-
if not k.startswith('_'):
118-
if callable(v):
119-
copied_values[k] = v
120-
else:
121-
copied_values[k] = copy.deepcopy(v, memo)
122-
result = cls.model_construct(**copied_values)
123-
memo[id(self)] = result
124-
return result
84+
"""Configuration for A2A remote agents."""
85+
86+
# Converts standard A2A Messages into ADK Event.
87+
a2a_message_converter: A2AMessageToEventConverter = (
88+
convert_a2a_message_to_event
89+
)
90+
91+
# Converts an A2A Task into an ADK Event.
92+
a2a_task_converter: A2ATaskToEventConverter = convert_a2a_task_to_event
93+
94+
# Converts A2A TaskStatusUpdateEvents into ADK Event.
95+
a2a_status_update_converter: A2AStatusUpdateToEventConverter = (
96+
convert_a2a_status_update_to_event
97+
)
98+
99+
# Converts A2A TaskArtifactUpdateEvents into ADK Event.
100+
a2a_artifact_update_converter: A2AArtifactUpdateToEventConverter = (
101+
convert_a2a_artifact_update_to_event
102+
)
103+
104+
# A low-level hook that converts individual A2A Message Parts
105+
# into native ADK/GenAI Part objects.
106+
# This is utilized internally by the other converters.
107+
a2a_part_converter: A2APartToGenAIPartConverter = (
108+
convert_a2a_part_to_genai_part
109+
)
110+
111+
request_interceptors: Optional[list[RequestInterceptor]] = None
112+
113+
def __deepcopy__(self, memo):
114+
cls = self.__class__
115+
copied_values = {}
116+
for k, v in self.__dict__.items():
117+
if not k.startswith("_"):
118+
if callable(v):
119+
copied_values[k] = v
120+
else:
121+
copied_values[k] = copy.deepcopy(v, memo)
122+
result = cls.model_construct(**copied_values)
123+
memo[id(self)] = result
124+
return result

0 commit comments

Comments
 (0)