Python: Clean left-over WorkflowCompletedEvent (#884)

* Clean left-over WorkflowCompletedEvent

* Improve comments

* Fix type check error
This commit is contained in:
Tao Chen
2025-09-23 17:52:51 -07:00
committed by GitHub
Unverified
parent 06827e9f1a
commit 36933de345
7 changed files with 18 additions and 19 deletions
@@ -1621,7 +1621,7 @@ class AgentExecutor(Executor):
async def _run_agent_and_emit(self, ctx: WorkflowContext[AgentExecutorResponse]) -> None:
"""Execute the underlying agent, emit events, and enqueue response.
Terminal detection & WorkflowCompletedEvent emission are handled centrally in Runner.
Terminal detection is handled centrally in Runner.
This method only produces AgentRunEvent/AgentRunUpdateEvent plus enqueues an
AgentExecutorResponse message for routing.
"""
@@ -288,7 +288,7 @@ class Runner:
tasks = [_deliver_message_inner(edge_runner, message) for edge_runner in associated_edge_runners]
if not tasks:
# No outgoing edges. If this is an AgentExecutorResponse, treat it as an
# intentional terminal emission and emit a WorkflowCompletedEvent here.
# intentional terminal emission and emit a WorkflowOutputEvent here.
# (Previously this relied on the executor to emit, but AgentExecutor only
# sends an AgentExecutorResponse message; centralized completion keeps the
# contract consistent with other executors.)