Repository navigation
Conversation
A task sub-agent that raised ended the parent's turn and left its function call unanswered in the session, so every later message dispatched it again and failed the same way. The call now gets an error function response that the parent's model can read. Wiring errors and interrupts still propagate. Fixes google#8241
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
When a task-mode sub-agent raised (for example its model call failed),
_dispatch_task_fclet the child'sDynamicNodeFailErrorescape. The parent's turn failed, and the delegation's function call stayed in the session with no response._find_unresolved_task_delegationsthen dispatched that call again at the start of every later turn, so every later message in the session failed the same way, even one that had nothing to do with the sub-agent.Solution:
_dispatch_task_fccatchesDynamicNodeFailErrorand returns{"error": "<Type>: <message>", "is_error": True}, which_synthesize_task_fr_eventturns into the call's function response. The parent's model reads the error and replies, and the call is answered, so later turns do not dispatch it again.What still propagates, as before:
WorkflowConfigurationErrorandWorkflowInvariantErrorfrom the task (a miswired agent tree is not the task's answer).NodeInterruptedError(a task waiting on the user), which is aBaseExceptionand is not caught.Behavior change: a task sub-agent that raises no longer fails the parent's turn. The parent's model gets the error as the call's response instead.
flowchart TD A[Task sub-agent raises] --> B{Parent turn} B -->|Before| C[Turn fails and every later message fails too] B -->|After| D[Model reads the error and later messages work]Narrated recording, before then after (sound on):
evidence.mp4
Testing Plan
Unit Tests:
New test
test_failed_task_answers_its_call_with_the_errorintests/unittests/workflow/test_task_api_e2e.py: a task sub-agent whose model raises; it checks the call's function response is the error, that the parent's model replies, and that the next message reaches the model.After merging current
main(c38ecda) into the branch:The 5 errors are collection errors in modules that need optional extras not installed here (
workflow/utils/test_workflow_graph_utils.py,agents/test_agent_config.py,agents/test_llm_agent_fields.py,agents/test_mcp_instruction_provider.py,test_runners.py).pyinkandisortwith the repo config leave the changed files unchanged.Manual End-to-End (E2E) Tests:
chat.pyis the issue's script with a scriptedBaseLlm(no API key): a root chat agent with one task sub-agenthelper, sent three messages. The argument picks what the helper's model does:failsraisesRuntimeError,workscallsfinish_task,miswiredraisesWorkflowConfigurationError.On main:
On this branch:
Edge cases and unchanged behaviour checked (in the recording, on this branch):
helper said {'result': '42'}), and plain messages are unchanged.WorkflowConfigurationErrorfrom the helper still fails the run, as before.Checklist
Additional context
This change was prepared with AI assistance (Claude Code), which also ran the tests and recorded the runs shown above.
🤖 Generated with Claude Code