A cloud run deployed solution often fails to produce the answer from the final agent in a sequential setting, it is often preceded by a tool warning (perplexity returning images perhaps) resulting in this message:
Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/opentelemetry/context/__init__.py", line 155, in detach _RUNTIME_CONTEXT.detach(token) File "/app/.venv/lib/python3.12/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 0x3e76d85ef7e0> at 0x3e76c8542780> was created in a different Context
There is no clear indication from which part of ADK does this rise.
Tool warning
"Warning: there are non-text parts in the response: ['function_call'], returning concatenated text result from text parts. Check the full candidates.content.parts accessor to get the full model response."
Built some enhanced logging and got this out of it. Context that is passed from first agent to consecuent agents is lost for some reason in the shared context registry. Some agents find it some dont. I tried building a tool that could write memories after certain events but your memory implementation only supports writing the whole session to memory and not writing during events. Fetching large contexts from memory instead of the shared context could be backup plan in many cases.
Improved logging
2025-05-30 12:10:24.961 EEST Error in event_generator: 'Context variable not found:data_collector_text_output.' Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/google/adk/cli/fast_api.py", line 806, in event_generator async for event in runner.run_async( File "/app/.venv/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 "/app/.venv/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 "/app/.venv/lib/python3.12/site-packages/google/adk/agents/sequential_agent.py", line 37, in _run_async_impl async for event in sub_agent.run_async(ctx): File "/app/.venv/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 "/app/.venv/lib/python3.12/site-packages/google/adk/agents/parallel_agent.py", line 95, in _run_async_impl async for event in _merge_agent_run(agent_runs): File "/app/.venv/lib/python3.12/site-packages/google/adk/agents/parallel_agent.py", line 65, in _merge_agent_run yield task.result() ^^^^^^^^^^^^^ File "/app/.venv/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 "/app/.venv/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 "/app/.venv/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 "/app/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 293, in _run_one_step_async async for event in self._preprocess_async(invocation_context, llm_request): File "/app/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 327, in _preprocess_async async for event in processor.run_async(invocation_context, llm_request): File "/app/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/instructions.py", line 73, in run_async si = await _populate_values(raw_si, invocation_context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/instructions.py", line 131, in _populate_values return await _async_sub(r'{+[^{}]*}+', _replace_match, instruction_template) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/instructions.py", line 95, in _async_sub replacement = await repl_async_fn(match) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/instructions.py", line 129, in _replace_match raise KeyError(f'Context variable not found: {var_name}.') KeyError: 'Context variable not found: data_collector_text_output`.'
2025-05-30 12:10:24.962 EEST
Error in event_generator: 'Context variable not found: data_collector_text_output.'`
To Reproduce
Multi-agent orchestrator with search tools and large amount of context being used to synthetize the final answer
ADK 1.1.0
Gemini-2.5-pro-preview-05-06
A cloud run deployed solution often fails to produce the answer from the final agent in a sequential setting, it is often preceded by a tool warning (perplexity returning images perhaps) resulting in this message:
Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/opentelemetry/context/__init__.py", line 155, in detach _RUNTIME_CONTEXT.detach(token) File "/app/.venv/lib/python3.12/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 0x3e76d85ef7e0> at 0x3e76c8542780> was created in a different ContextThere is no clear indication from which part of ADK does this rise.
Tool warning
"Warning: there are non-text parts in the response: ['function_call'], returning concatenated text result from text parts. Check the full candidates.content.parts accessor to get the full model response."Built some enhanced logging and got this out of it. Context that is passed from first agent to consecuent agents is lost for some reason in the shared context registry. Some agents find it some dont. I tried building a tool that could write memories after certain events but your memory implementation only supports writing the whole session to memory and not writing during events. Fetching large contexts from memory instead of the shared context could be backup plan in many cases.
Improved logging
2025-05-30 12:10:24.961 EEST Error in event_generator: 'Context variable not found:data_collector_text_output.' Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/google/adk/cli/fast_api.py", line 806, in event_generator async for event in runner.run_async( File "/app/.venv/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 "/app/.venv/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 "/app/.venv/lib/python3.12/site-packages/google/adk/agents/sequential_agent.py", line 37, in _run_async_impl async for event in sub_agent.run_async(ctx): File "/app/.venv/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 "/app/.venv/lib/python3.12/site-packages/google/adk/agents/parallel_agent.py", line 95, in _run_async_impl async for event in _merge_agent_run(agent_runs): File "/app/.venv/lib/python3.12/site-packages/google/adk/agents/parallel_agent.py", line 65, in _merge_agent_run yield task.result() ^^^^^^^^^^^^^ File "/app/.venv/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 "/app/.venv/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 "/app/.venv/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 "/app/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 293, in _run_one_step_async async for event in self._preprocess_async(invocation_context, llm_request): File "/app/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 327, in _preprocess_async async for event in processor.run_async(invocation_context, llm_request): File "/app/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/instructions.py", line 73, in run_async si = await _populate_values(raw_si, invocation_context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/instructions.py", line 131, in _populate_values return await _async_sub(r'{+[^{}]*}+', _replace_match, instruction_template) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/instructions.py", line 95, in _async_sub replacement = await repl_async_fn(match) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/instructions.py", line 129, in _replace_match raise KeyError(f'Context variable not found:{var_name}.') KeyError: 'Context variable not found:data_collector_text_output`.'2025-05-30 12:10:24.962 EEST
Error in event_generator: 'Context variable not found:
data_collector_text_output.'`To Reproduce
Multi-agent orchestrator with search tools and large amount of context being used to synthetize the final answer
ADK 1.1.0
Gemini-2.5-pro-preview-05-06