← Back to PRs

#8893: fix: enhance subagent error reporting with diagnostic context

by joetomasone open 2026-02-04 15:29 View on GitHub →
gateway commands agents stale
## Problem When a sub-agent fails, the parent agent only receives `{ status: 'error', error: 'message' }`. This minimal information makes it hard for the orchestrating agent to: - Understand what went wrong - Decide whether to retry - Report meaningful status to the user ## Solution Expand `SubagentRunOutcome` to include: - `lastTool`: Which tool was executing when the failure occurred - `completedSteps`: How many steps succeeded before the failure - `partialProgress`: Any partial results before the error Update the status label formatting to include this context in announcements. ## Example Before: ``` failed: connection timeout ``` After: ``` failed: connection timeout (last tool: exec) (completed 3 steps before failure) ``` ## Impact - Better debugging for batch operations - Orchestrating agent can make smarter retry decisions - More informative error messages for users Note: This is a forward-compatible change. The new fields are optional and existing code will continue to work. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR expands `SubagentRunOutcome` to optionally include richer diagnostics (`lastTool`, `completedSteps`, `partialProgress`) and updates the announce/status label formatting to surface that context in user-facing announcements. The main integration point is the subagent registry’s lifecycle listener (`onAgentEvent`), which now reads these fields from error events and persists them into the run record so `runSubagentAnnounceFlow` can incorporate them into its status text. <h3>Confidence Score: 3/5</h3> - Mostly safe, but the new diagnostics won’t consistently propagate on the primary completion path. - The change is small and localized, but `agent.wait`-based completion currently drops the new fields, meaning the intended behavior is only present for lifecycle-event errors. That inconsistency is likely to be noticed in production debugging and reduces confidence. - src/agents/subagent-registry.ts and src/agents/subagent-announce.ts (agent.wait outcome construction) <!-- greptile_other_comments_section --> <sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs