Error while following the sample conversation in fomc-research
I had updated the pyproject.toml of fomc-research sample project to google-adk 0.4.0 and I was trying to follow the sample conversion in the README.
When I give the date, I am getting the following error. Can someone help check the issue
RuntimeWarning: coroutine 'InMemoryArtifactService.list_artifact_keys' was never awaited
async for artifact_name in runner.artifact_service.list_artifact_keys(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Error in event_generator: 'async for' requires an object with __aiter__ method, got coroutine
Traceback (most recent call last):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/cli/fast_api.py", line 626, in event_generator
async for event in runner.run_async(
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/runners.py", line 197, in run_async
async for event in invocation_context.agent.run_async(invocation_context):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/agents/base_agent.py", line 127, in run_async
async for event in self._run_async_impl(ctx):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/agents/llm_agent.py", line 227, in _run_async_impl
async for event in self._llm_flow.run_async(ctx):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 231, in run_async
async for event in self._run_one_step_async(invocation_context):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 261, in _run_one_step_async
async for event in self._postprocess_async(
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 329, in _postprocess_async
async for event in self._postprocess_handle_function_calls_async(
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 419, in _postprocess_handle_function_calls_async
async for event in agent_to_run.run_async(invocation_context):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/agents/base_agent.py", line 127, in run_async
async for event in self._run_async_impl(ctx):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/agents/llm_agent.py", line 227, in _run_async_impl
async for event in self._llm_flow.run_async(ctx):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 231, in run_async
async for event in self._run_one_step_async(invocation_context):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 261, in _run_one_step_async
async for event in self._postprocess_async(
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 329, in _postprocess_async
async for event in self._postprocess_handle_function_calls_async(
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 404, in _postprocess_handle_function_calls_async
if function_response_event := await functions.handle_function_calls_async(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/functions.py", line 165, in handle_function_calls_async
function_response = await __call_tool_async(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/functions.py", line 430, in __call_tool_async
return await tool.run_async(args=args, tool_context=tool_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/tools/agent_tool.py", line 149, in run_async
async for artifact_name in runner.artifact_service.list_artifact_keys(
TypeError: 'async for' requires an object with __aiter__ method, got coroutine
2025-05-08 12:04:09,866 - ERROR - __init__.py:157 - Failed to detach context
Traceback (most recent call last):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/opentelemetry/trace/__init__.py", line 587, in use_span
yield span
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/opentelemetry/sdk/trace/__init__.py", line 1105, in start_as_current_span
yield span
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/opentelemetry/trace/__init__.py", line 452, in start_as_current_span
yield span
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 487, in _call_llm_async
yield llm_response
GeneratorExit
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/opentelemetry/context/__init__.py", line 155, in detach
_RUNTIME_CONTEXT.detach(token)
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/opentelemetry/context/contextvars_context.py", line 53, in detach
self._current_context.reset(token)
ValueError: <Token var=<ContextVar name='current_context' default={} at 0x105861b70> at 0x11fd38880> was created in a different Context
2025-05-08 12:04:09,868 - ERROR - __init__.py:157 - Failed to detach context
Traceback (most recent call last):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/opentelemetry/trace/__init__.py", line 587, in use_span
yield span
File "/Users/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/opentelemetry/sdk/trace/__init__.py", line 1105, in start_as_current_span
yield span
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/opentelemetry/trace/__init__.py", line 452, in start_as_current_span
yield span
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 487, in _call_llm_async
yield llm_response
GeneratorExit
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/opentelemetry/context/__init__.py", line 155, in detach
_RUNTIME_CONTEXT.detach(token)
File "/Users/abhi/adk-samples/adk-samples/agents/fomc-research/.venv/lib/python3.11/site-packages/opentelemetry/context/contextvars_context.py", line 53, in detach
self._current_context.reset(token)
ValueError: <Token var=<ContextVar name='current_context' default={} at 0x105861b70> at 0x11fd17cc0> was created in a different Context
Mike can you help with this issue?
Update to the current version and google-adk 0.5.0 and try again. The ADK API changed to use async calls (I think between 0.4 and 0.5). My last commit updated all the agents to use google-adk 0.5.0 and async calls for the Artifact Service, so it should work now.
@mstyer-google , @turanbulmus I tried with the latest version of ADK 1.0.0 and seems like this issue is no longer happening. But now I am facing a different issue. Seems like the agent is able to complete multiple more steps before failing.
2025-05-21 17:54:11,758 - ERROR - fast_api.py:817 - Error in event_generator: 'coroutine' object has no attribute 'inline_data'
Traceback (most recent call last):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/cli/fast_api.py", line 806, in event_generator
async for event in runner.run_async(
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/runners.py", line 196, in run_async
async for event in invocation_context.agent.run_async(invocation_context):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/agents/base_agent.py", line 147, in run_async
async for event in self._run_async_impl(ctx):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/agents/llm_agent.py", line 278, in _run_async_impl
async for event in self._llm_flow.run_async(ctx):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 279, in run_async
async for event in self._run_one_step_async(invocation_context):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 309, in _run_one_step_async
async for event in self._postprocess_async(
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 381, in _postprocess_async
async for event in self._postprocess_handle_function_calls_async(
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 471, in _postprocess_handle_function_calls_async
async for event in agent_to_run.run_async(invocation_context):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/agents/base_agent.py", line 147, in run_async
async for event in self._run_async_impl(ctx):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/agents/llm_agent.py", line 278, in _run_async_impl
async for event in self._llm_flow.run_async(ctx):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 279, in run_async
async for event in self._run_one_step_async(invocation_context):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 309, in _run_one_step_async
async for event in self._postprocess_async(
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 381, in _postprocess_async
async for event in self._postprocess_handle_function_calls_async(
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 471, in _postprocess_handle_function_calls_async
async for event in agent_to_run.run_async(invocation_context):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/agents/base_agent.py", line 147, in run_async
async for event in self._run_async_impl(ctx):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/agents/llm_agent.py", line 278, in _run_async_impl
async for event in self._llm_flow.run_async(ctx):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 279, in run_async
async for event in self._run_one_step_async(invocation_context):
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 309, in _run_one_step_async
async for event in self._postprocess_async(
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 381, in _postprocess_async
async for event in self._postprocess_handle_function_calls_async(
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 456, in _postprocess_handle_function_calls_async
if function_response_event := await functions.handle_function_calls_async(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/functions.py", line 166, in handle_function_calls_async
function_response = await __call_tool_async(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/flows/llm_flows/functions.py", line 431, in __call_tool_async
return await tool.run_async(args=args, tool_context=tool_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/atheyyathamkandi/Library/Caches/pypoetry/virtualenvs/fomc-research-g_MCAVRP-py3.12/lib/python3.12/site-packages/google/adk/tools/function_tool.py", line 82, in run_async
return self.func(**args_to_call) or {}
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/atheyyathamkandi/cosmos-projects/adk-samples/adk-samples/agents/fomc-research/fomc_research/tools/compare_statements.py", line 64, in compare_statements_tool
reqd_pdf_text = file_utils.extract_text_from_pdf_artifact(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/atheyyathamkandi/cosmos-projects/adk-samples/adk-samples/agents/fomc-research/fomc_research/shared_libraries/file_utils.py", line 73, in extract_text_from_pdf_artifact
base64.b64decode(pdf_artifact.inline_data.data)
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'coroutine' object has no attribute 'inline_data'
ADK 1.0 introduces more breaking changes and I haven't updated the fomc-research sample agent to be compatible yet. It should work with ADK 0.5.0 though, and the version specification in pyproject.toml should prevent you from updating to 1.0 unless you change it. I'm working on updating the sample agents to be compatible with 1.0, but it's still in progress.
If you have issues running the agent with ADK 0.5.0, let me know. If it's just with 1.0, I'd suggest waiting until we release the compatible version.
It looks like this was an issue with the ADK 1.0 release. All those issues should have been fixed now; please re-open if this is still occurring.