mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: aclose all async generators to fix OTel tracing context
See https://github.com/google/adk-python/issues/1670#issuecomment-3115891100 PiperOrigin-RevId: 794659547
This commit is contained in:
committed by
Copybara-Service
parent
c5af44cfc0
commit
a30c63c593
@@ -24,6 +24,8 @@ from typing import Callable
|
||||
from typing import Optional
|
||||
import uuid
|
||||
|
||||
from ...utils.context_utils import Aclosing
|
||||
|
||||
try:
|
||||
from a2a.server.agent_execution import AgentExecutor
|
||||
from a2a.server.agent_execution.context import RequestContext
|
||||
@@ -212,12 +214,13 @@ class A2aAgentExecutor(AgentExecutor):
|
||||
)
|
||||
|
||||
task_result_aggregator = TaskResultAggregator()
|
||||
async for adk_event in runner.run_async(**run_args):
|
||||
for a2a_event in convert_event_to_a2a_events(
|
||||
adk_event, invocation_context, context.task_id, context.context_id
|
||||
):
|
||||
task_result_aggregator.process_event(a2a_event)
|
||||
await event_queue.enqueue_event(a2a_event)
|
||||
async with Aclosing(runner.run_async(**run_args)) as agen:
|
||||
async for adk_event in agen:
|
||||
for a2a_event in convert_event_to_a2a_events(
|
||||
adk_event, invocation_context, context.task_id, context.context_id
|
||||
):
|
||||
task_result_aggregator.process_event(a2a_event)
|
||||
await event_queue.enqueue_event(a2a_event)
|
||||
|
||||
# publish the task result event - this is final
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user