|
@node |
|
def city_time_function(city: str): |
|
"""Simulate returning the current time in a specified city.""" |
|
return CityTime(time_info="10:10 AM", city=city) |
|
|
|
city_report_agent = Agent( |
|
name="city_report_agent", |
|
model="gemini-flash-latest", |
|
input_schema=CityTime, |
|
instruction="""output the data provided by the previous node.""", |
|
) |
|
|
|
@node # workflow node |
|
async def city_workflow(ctx: Context): |
|
city_time = await ctx.run_node(city_time_function, "Paris") |
|
report_text = await ctx.run_node(city_report_agent, city_time) |
|
|
|
return report_text |
|
``` |
Test code:
@node
def city_time_function(city: str):
return "Hello"
@node(rerun_on_resume=True)
async def city_workflow(ctx: Context):
city_time = await ctx.run_node(city_time_function, "Paris")
return city_time
session_service = InMemorySessionService()
session = await session_service.create_session(app_name=APP_NAME, user_id=USER_ID, session_id=SESSION_ID)
runner = Runner(agent=city_workflow, app_name=APP_NAME, session_service=session_service)
content = types.Content(role='user', parts=[types.Part(text="hello")])
events = runner.run(user_id=USER_ID, session_id=SESSION_ID, new_message=content)
for event in events:
pass
Error:
ValueError: Missing value for parameter "city" of function "city_time_function". It was not found in state and has no default value.
Changeing to node_input works:
@node
def city_time_function(node_input: str):
return "Hello"
Python 3.14.6
google-adk==2.6.3
adk-docs/docs/graphs/dynamic.md
Lines 247 to 265 in ab74986
Test code:
Error:
Changeing to node_input works:
Python 3.14.6
google-adk==2.6.3