Fix handoff workflow context management and improve AG-UI demo (#5136)

This commit is contained in:
Evan Mattson
2026-04-08 13:08:24 +09:00
committed by GitHub
Unverified
parent f94a75daa5
commit e10d448ae2
19 changed files with 601 additions and 252 deletions
@@ -339,6 +339,13 @@ class AgentExecutor(Executor):
ctx.get_state(WORKFLOW_RUN_KWARGS_KEY, {})
)
if not self._cache:
logger.warning(
"AgentExecutor %s: Running agent with empty message cache. "
"This could lead to service error for some LLM providers.",
self.id,
)
run_agent = cast(Callable[..., Awaitable[AgentResponse[Any]]], self._agent.run)
response = await run_agent(
self._cache,
@@ -371,6 +378,13 @@ class AgentExecutor(Executor):
ctx.get_state(WORKFLOW_RUN_KWARGS_KEY, {})
)
if not self._cache:
logger.warning(
"AgentExecutor %s: Running agent with empty message cache. "
"This could lead to service error for some LLM providers.",
self.id,
)
updates: list[AgentResponseUpdate] = []
streamed_user_input_requests: list[Content] = []
run_agent_stream = cast(Callable[..., ResponseStream[AgentResponseUpdate, AgentResponse[Any]]], self._agent.run)
@@ -186,6 +186,12 @@ class Runner:
"""Inner loop to deliver a single message through an edge runner."""
return await edge_runner.send_message(message, self._state, self._ctx)
async def _deliver_messages_for_edge_runner(edge_runner: EdgeRunner) -> None:
# Preserve message order per edge runner (and therefore per routed target path)
# while still allowing parallelism across different edge runners.
for message in source_messages:
await _deliver_message_inner(edge_runner, message)
# Route all messages through normal workflow edges
associated_edge_runners = self._edge_runner_map.get(source_executor_id, [])
if not associated_edge_runners:
@@ -193,12 +199,6 @@ class Runner:
logger.debug(f"No outgoing edges found for executor {source_executor_id}; dropping messages.")
return
async def _deliver_messages_for_edge_runner(edge_runner: EdgeRunner) -> None:
# Preserve message order per edge runner (and therefore per routed target path)
# while still allowing parallelism across different edge runners.
for message in source_messages:
await _deliver_message_inner(edge_runner, message)
tasks = [_deliver_messages_for_edge_runner(edge_runner) for edge_runner in associated_edge_runners]
await asyncio.gather(*tasks)