Required prerequisites
Motivation
Problem
SingleAgentWorker._process_task has three issues:
- Two separate streaming consumption paths — structured-handler and native-structured-output each inline their own
async for chunk in response loop. They differ in content accumulation (delta vs cumulative not handled), TaskResult extraction, and stream_callback forwarding. Bug fixes must be applied twice.
- No task-scoped execution context — worker agents have no way to know which task/attempt they're executing. Downstream (eigent) needs task_id, attempt number, and agent IDs on every lifecycle event for debugging and telemetry, but must patch this externally.
- Flat, minimal attempt records —
worker_attempts entries contain only response_content[:50], tool_calls[:50], and total_tokens. Full token usage (prompt_tokens, etc.), tool call count, and execution context are lost.
- Agent pool context leakage — when an agent is returned to the pool,
_execution_context from the previous task is not cleared, potentially leaking to the next borrower.
Solution
No response
Alternatives
No response
Additional context
No response
Required prerequisites
Motivation
Problem
SingleAgentWorker._process_taskhas three issues:async for chunk in responseloop. They differ in content accumulation (delta vs cumulative not handled),TaskResultextraction, andstream_callbackforwarding. Bug fixes must be applied twice.worker_attemptsentries contain onlyresponse_content[:50],tool_calls[:50], andtotal_tokens. Full token usage (prompt_tokens, etc.), tool call count, and execution context are lost._execution_contextfrom the previous task is not cleared, potentially leaking to the next borrower.Solution
No response
Alternatives
No response
Additional context
No response