fix(agents): surface recovered subagent termination reasons#22325
fix(agents): surface recovered subagent termination reasons#22325matei-anghel wants to merge 5 commits intogoogle-gemini:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request improves the transparency of subagent recovery by ensuring that when a subagent successfully recovers from an initial termination condition, the system explicitly records and displays the original reason for the interruption. This change prevents recovered runs from appearing as simple successes, offering users and telemetry systems a clearer understanding of the agent's operational flow and any underlying issues it overcame. The modifications span across agent execution logic, output rendering, and various telemetry logging mechanisms. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to surface the original termination reason for subagents that successfully recover from errors like timeouts or exceeding turn limits. The changes are well-implemented across the agent execution logic, telemetry, and metrics systems. A new recovered_from field is added to the agent output and telemetry events, providing better visibility into agent behavior without breaking the parent agent's workflow. The code is clean, type-safe, and includes comprehensive tests for the new functionality. I have no major concerns with this change.
Note: Security Review did not run due to the size of the PR.
Summary
Surface recovered subagent termination reasons so recovered runs are not presented as plain clean
GOALsuccesses.Details
This change keeps the current recovery behavior for local subagents, but preserves the original recoverable stop reason when recovery succeeds.
When a subagent hits
MAX_TURNS,TIMEOUT, orERROR_NO_COMPLETE_TASK_CALLand the recovery turn succeeds, the final output now keeps:terminate_reason=GOALrecovered_from=<original reason>This is surfaced in:
This keeps recovered runs usable by the parent agent while making the interruption visible to users and telemetry.
Related Issues
Fixes #22323
How to Validate
Run:
npm run build cd packages/core npx vitest run src/agents/local-executor.test.ts src/agents/local-invocation.test.ts src/agents/browser/browserAgentInvocation.test.ts src/telemetry/loggers.test.ts src/telemetry/metrics.test.ts src/telemetry/clearcut-logger/clearcut-logger.test.tsExpected results:
Recovered From: <reason>GOALcompletions do not includerecovered_fromPre-Merge Checklist