Repository navigation
fix(agent-status): surface tool-failure errors across Cursor/Copilot/Grok - #8483
Conversation
Extract a shared clearActiveToolFieldsUpdate() helper and apply it to Cursor's postToolUseFailure, Copilot's PostToolUseFailure/ErrorOccurred, and Grok's post_tool_use_failure events, matching the existing Claude behavior so the failure message surfaces instead of the last tool name.
📝 WalkthroughWalkthroughAgent hook normalization now clears cached tool name, input, and interactive prompt fields when Claude, Cursor, Copilot, or Grok tool failures occur. Failure text continues to populate 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/shared/agent-hook-listener.ts (1)
1773-1777: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a test for Copilot
ErrorOccurredclearing behavior.
ErrorOccurredis now routed throughclearActiveToolFieldsUpdate()alongsidePostToolUseFailure, but onlyPostToolUseFailurehas test coverage inserver.test.ts. A dedicated test would guard against accidental removal ofErrorOccurredfrom the condition.🧪 Suggested test for ErrorOccurred
it('PostToolUseFailure surfaces the error and clears stale tool fields', () => { // ... existing test ... }) + + it('ErrorOccurred surfaces the error and clears stale tool fields', () => { + _internals.normalizeHookPayload( + 'copilot', + buildBody({ + hook_event_name: 'PreToolUse', + toolName: 'bash', + toolInput: { command: 'pnpm test' } + }), + 'production' + ) + const failed = _internals.normalizeHookPayload( + 'copilot', + buildBody({ + hook_event_name: 'ErrorOccurred', + toolName: 'bash', + toolInput: { command: 'pnpm test' }, + error_message: 'agent crashed' + }), + 'production' + ) + expect(failed?.payload).toMatchObject({ + state: 'working', + lastAssistantMessage: 'agent crashed' + }) + expect(failed?.payload.toolName).toBeUndefined() + expect(failed?.payload.toolInput).toBeUndefined() + })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 1cee47b9-a324-414c-84c4-5c172f7869cb
📒 Files selected for processing (3)
src/main/agent-hooks/server.test.tssrc/shared/agent-hook-listener.test.tssrc/shared/agent-hook-listener.ts
…Grok (stablyai#8483) * fix(agent-status): surface Claude tool failures * Fix compact sidebar hiding tool-failure errors behind stale tool name Extract a shared clearActiveToolFieldsUpdate() helper and apply it to Cursor's postToolUseFailure, Copilot's PostToolUseFailure/ErrorOccurred, and Grok's post_tool_use_failure events, matching the existing Claude behavior so the failure message surfaces instead of the last tool name.
What & why
When an agent's tool call fails, the compact sidebar was showing the stale tool name/input instead of the failure error, hiding the error from the user. The sidebar prioritizes active-tool metadata over the failure message, so a just-failed tool that still looks "in-flight" masks the error text.
This extracts a shared
clearActiveToolFieldsUpdate()helper insrc/shared/agent-hook-listener.tsthat clearstoolName/toolInput/interactivePrompton tool-failure events, so the failure message surfaces instead. It's applied uniformly across the agents that emit tool-failure hooks:PostToolUseFailurepostToolUseFailurePostToolUseFailureandErrorOccurredpost_tool_use_failureThe failure error text is still surfaced as
lastAssistantMessagefor every agent (that logic runs after the clear and is unchanged). The clear composes withresolveToolState's existingclearsUnidentifiedTool/clearsUnpreviewableInputpaths so the fields drop rather than inheriting stale values, and a subsequentPreToolUserestores normal tool display.Testing
toolName/toolInputwhile surfacing the error, plus a Claude retry case confirming the nextPreToolUserestores tool fields.pnpm typecheckpasses.Made with Orca 🐋