Skip to content

Conversation

@cezudas
Copy link
Contributor

@cezudas cezudas commented Jan 27, 2026

Fixes OPS-3493.

@linear
Copy link

linear bot commented Jan 27, 2026

@cezudas cezudas marked this pull request as ready for review January 27, 2026 08:33
Copilot AI review requested due to automatic review settings January 27, 2026 08:33
Copy link
Contributor

Copilot AI left a 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: true and 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.

@cezudas cezudas requested a review from MarceloRGonc January 27, 2026 17:36
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants