MCPcopy Index your code
hub / github.com/google/adk-python / call_agent_async

Function call_agent_async

contributing/samples/tools/pydantic_argument/main.py:33–49  ·  view source on GitHub ↗

Helper function to call the agent and return response.

(runner, user_id, session_id, prompt)

Source from the content-addressed store, hash-verified

31
32
33async def call_agent_async(runner, user_id, session_id, prompt):
34 """Helper function to call the agent and return response."""
35 content = types.Content(
36 role="user", parts=[types.Part.from_text(text=prompt)]
37 )
38
39 final_response_text = ""
40 async for event in runner.run_async(
41 user_id=user_id,
42 session_id=session_id,
43 new_message=content,
44 run_config=RunConfig(save_input_blobs_as_artifacts=False),
45 ):
46 if hasattr(event, "content") and event.content:
47 final_response_text += event.content
48
49 return final_response_text
50
51
52async def main():

Callers 1

mainFunction · 0.70

Calls 2

RunConfigClass · 0.90
run_asyncMethod · 0.45

Tested by

no test coverage detected