Skip to content

Commit eb54b5e

Browse files
xumapleclaude
andauthored
AI-284: Add snipsync markers and trim comments in Google ADK samples (#321)
Add SNIPSTART markers around the Worker/Client setup and Workflow starter so the documentation integration page can pull them via snipsync, and trim the sample comments to short, why-only notes. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f65112a commit eb54b5e

12 files changed

Lines changed: 21 additions & 36 deletions

File tree

google_adk_agents/agent_patterns/run_worker.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313

1414
async def main():
15-
# Build the plugin once and give the same instance to the client and the
16-
# worker.
1715
plugin = GoogleAdkPlugin()
1816

1917
client = await Client.connect("localhost:7233", plugins=[plugin])

google_adk_agents/agent_patterns/workflows/multi_agent_workflow.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ async def run(self, topic: str) -> str:
1919
app_name="multi_agent_app", user_id="user"
2020
)
2121

22-
# Give each sub-agent its own TemporalModel with an ActivityConfig
23-
# summary, so its model turns show up as named activities in history.
22+
# The ActivityConfig summary makes each model turn a named activity in
23+
# history.
2424
researcher = LlmAgent(
2525
name="researcher",
2626
model=TemporalModel(
@@ -39,8 +39,7 @@ async def run(self, topic: str) -> str:
3939
instruction="You are a poet. Write a haiku based on the research.",
4040
)
4141

42-
# The coordinator hands off to the sub-agents using ADK's built-in
43-
# transfer_to_agent, which runs durably here.
42+
# ADK's transfer_to_agent handoff runs durably here.
4443
coordinator = LlmAgent(
4544
name="coordinator",
4645
model=TemporalModel(

google_adk_agents/basic/run_hello_world_workflow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010

1111
async def main():
12+
# @@@SNIPSTART google-adk-agents-basic-starter
1213
client = await Client.connect("localhost:7233", plugins=[GoogleAdkPlugin()])
1314

1415
result = await client.execute_workflow(
@@ -18,6 +19,7 @@ async def main():
1819
task_queue="google-adk-agents-basic",
1920
)
2021
print(f"Result: {result}")
22+
# @@@SNIPEND
2123

2224

2325
if __name__ == "__main__":

google_adk_agents/basic/run_worker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313

1414
async def main():
15-
# Build the plugin once and give the same instance to the client and the
16-
# worker.
15+
# @@@SNIPSTART google-adk-agents-basic-worker
1716
plugin = GoogleAdkPlugin()
1817

1918
client = await Client.connect("localhost:7233", plugins=[plugin])
@@ -25,6 +24,7 @@ async def main():
2524
plugins=[plugin],
2625
)
2726
await worker.run()
27+
# @@@SNIPEND
2828

2929

3030
if __name__ == "__main__":

google_adk_agents/basic/workflows/hello_world_workflow.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,20 @@
1111
class HelloWorldAgentWorkflow:
1212
@workflow.run
1313
async def run(self, prompt: str) -> str:
14-
# A normal ADK agent. The one Temporal-specific piece is TemporalModel,
15-
# which runs each model call as an `invoke_model` activity.
14+
# TemporalModel runs each model call as an `invoke_model` activity.
1615
agent = Agent(
1716
name="hello_world_agent",
1817
model=TemporalModel("gemini-2.5-flash"),
1918
instruction="You only respond in haikus.",
2019
)
2120

22-
# InMemoryRunner drives the agent. The plugin points ADK's session-id
23-
# generation at workflow.uuid4(), so creating a session here is
24-
# replay-safe.
21+
# The plugin points ADK's session-id generation at workflow.uuid4(), so
22+
# creating a session here is replay-safe.
2523
runner = InMemoryRunner(agent=agent, app_name="hello_world_app")
2624
session = await runner.session_service.create_session(
2725
app_name="hello_world_app", user_id="user"
2826
)
2927

30-
# Keep the last bit of text the agent produces.
3128
final_text = ""
3229
async with Aclosing(
3330
runner.run_async(

google_adk_agents/mcp/run_worker.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414

1515

1616
async def main():
17-
# The provider adds the echo-list-tools and echo-call-tool activities. Same
18-
# as the other samples: build the plugin once and give the same instance to
19-
# the client and the worker.
17+
# @@@SNIPSTART google-adk-agents-mcp-worker
2018
plugin = GoogleAdkPlugin(
2119
toolset_providers=[TemporalMcpToolSetProvider("echo", echo_toolset)]
2220
)
@@ -30,6 +28,7 @@ async def main():
3028
plugins=[plugin],
3129
)
3230
await worker.run()
31+
# @@@SNIPEND
3332

3433

3534
if __name__ == "__main__":

google_adk_agents/mcp/workflows/echo_workflow.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ class EchoMcpWorkflow:
1515
@workflow.run
1616
async def run(self, prompt: str) -> str:
1717
# TemporalMcpToolSet runs the MCP server's list-tools and call-tool
18-
# calls as activities (the provider names them echo-list-tools and
19-
# echo-call-tool on the worker). The not_in_workflow_toolset factory
20-
# lets you run this same agent locally, outside a workflow, by hitting
21-
# the MCP server directly.
18+
# calls as activities.
2219
agent = Agent(
2320
name="echo_agent",
2421
model=TemporalModel("gemini-2.5-flash"),

google_adk_agents/streaming/run_streaming_workflow.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@
1616
async def main():
1717
client = await Client.connect("localhost:7233", plugins=[GoogleAdkPlugin()])
1818

19-
# Start the workflow but don't wait on the result yet, so we can subscribe
20-
# to its stream while it's running.
2119
handle = await client.start_workflow(
2220
StreamingAgentWorkflow.run,
2321
"Tell me a short story about a robot learning to paint.",
2422
id=WORKFLOW_ID,
2523
task_queue="google-adk-agents-streaming",
2624
)
2725

28-
# Subscribe to the "responses" topic and print text chunks as they arrive.
2926
stream = WorkflowStreamClient.create(client, WORKFLOW_ID)
3027

3128
async def print_chunks() -> None:

google_adk_agents/streaming/run_worker.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313

1414
async def main():
15-
# Build the plugin once and give the same instance to the client and the
16-
# worker.
1715
plugin = GoogleAdkPlugin()
1816

1917
client = await Client.connect("localhost:7233", plugins=[plugin])

google_adk_agents/streaming/workflows/streaming_workflow.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
class StreamingAgentWorkflow:
1313
@workflow.init
1414
def __init__(self, prompt: str) -> None:
15-
# The workflow hosts a WorkflowStream. The streaming activity publishes
16-
# raw LlmResponse chunks to it as they come back from the model.
15+
# The streaming activity publishes LlmResponse chunks to this stream as
16+
# they come back from the model.
1717
self.stream = WorkflowStream()
1818

1919
@workflow.run
2020
async def run(self, prompt: str) -> str:
21-
# streaming_topic is the topic the chunks get published to.
22-
# RunConfig(streaming_mode=SSE) tells ADK to stream, which routes the
23-
# call through the invoke_model_streaming activity.
21+
# streaming_mode=SSE routes the call through the invoke_model_streaming
22+
# activity.
2423
model = TemporalModel("gemini-2.5-flash", streaming_topic="responses")
2524
agent = Agent(
2625
name="streaming_agent",

0 commit comments

Comments
 (0)