-
Notifications
You must be signed in to change notification settings - Fork 166
Add proper tool-error event tracking and persistence #1889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds proper tracking and persistence for tool error events in the AI chat system. When tool execution fails, the system now captures these errors, marks them appropriately, and wraps them in an MCP (Model Context Protocol) structure for consistent handling.
Changes:
- Track tool error events by collecting error tool call IDs during streaming
- Mark tool results with error flags when their corresponding tool calls failed
- Wrap error outputs in MCP structure with
isError: trueand standardized content format
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/server/api/src/app/ai/chat/user-message-handler.ts | Adds error tracking during streaming, marks tool results with error flags, and sends tool-error events with MCP-wrapped output |
| packages/server/api/src/app/ai/chat/utils.ts | Wraps error tool outputs in MCP structure when merging tool results into UI messages |
| packages/server/api/test/unit/ai/utils.test.ts | Adds test coverage for error tool result wrapping in MCP structure |
Comments suppressed due to low confidence (2)
packages/server/api/src/app/ai/chat/user-message-handler.ts:1
- The tool-error case duplicates the logic from the 'finish-step', 'finish', and 'tool-input-end' cases. This code block should be placed before the break statement of the existing combined case to eliminate duplication.
/* eslint-disable @typescript-eslint/no-explicit-any */
packages/server/api/src/app/ai/chat/user-message-handler.ts:373
- The toolName field is included in the tool-error case but not in the tool-result case above (line 384). This inconsistency could cause issues for consumers expecting a uniform structure. Either add toolName to the tool-result case or remove it from the tool-error case.
toolCallId: (message as any).toolCallId,
toolName: (message as any).toolName,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Marcelo Gonçalves <marcelo@openops.com>
|



Fixes OPS-3493.