fix: propagate error info from sub-agents to manager in ManagedAgent#2189
fix: propagate error info from sub-agents to manager in ManagedAgent#2189Ricardo-M-L wants to merge 2 commits intohuggingface:mainfrom
Conversation
|
Gentle bump — this one fixes #2166: |
VANDRANKI
left a comment
There was a problem hiding this comment.
Thanks for working on this - the problem is real. When ManagedAgent.__call__ silently returns an empty result on failure, the managing agent has no way to distinguish a task completion from a failure, which makes it hard to design reliable retry or escalation logic.
Rebase needed before review can continue
The diff currently shows src/smolagents/agents.py being deleted in its entirety (-1814 lines), with no replacement. This means the PR branch has diverged significantly from main and the actual code change is not visible in the diff. The only new content showing is the test file (+334 lines).
To unblock review:
git fetch upstream && git rebase upstream/mainon your branch- Resolve any conflicts in
agents.py(the file is still present on main atsrc/smolagents/agents.py) - Force-push the rebased branch
Once rebased, the diff will show only the targeted changes to ManagedAgent.__call__ and the tests, which makes it reviewable.
The test class TestManagedAgentErrorPropagation that is visible in the diff looks well-structured - once the rebase is done and the implementation is visible I would be happy to continue the review.
Summary
Fixes #2166
Problem: When a sub-agent hits tool errors or exhausts
max_steps,ManagedAgent.__call__returns empty/None to the manager. The manager cannot distinguish "completed with empty output" from "task failed", making informed retry decisions impossible.Root cause:
__call__callsself.run()with defaultreturn_full_result=False, discardingRunResult.state. Error information stored in memory steps is never surfaced to the manager.Fix:
__call__now always requestsRunResultto inspect the sub-agent's run state_collect_error_context()method inspects memory steps for: max_steps exhaustion, tool errors during execution, and empty results[WARNING]headers to the managed agent response when issues are detectedChanges
src/smolagents/agents.py: Modified__call__(+12 lines), added_collect_error_context(+63 lines)tests/test_agents.py: 7 new tests covering max_steps exhaustion, tool errors, successful runs, empty results, and unit tests for_collect_error_contextTest plan
pytest tests/test_agents.py::TestManagedAgentErrorPropagation— all 7 tests🤖 Generated with Claude Code