Skip to content

Conversation

@alexandrudanpop
Copy link
Contributor

Fixes OPS-3483

Copilot AI review requested due to automatic review settings January 27, 2026 15:51
@linear
Copy link

linear bot commented Jan 27, 2026

@alexandrudanpop alexandrudanpop requested review from cezudas and removed request for Copilot January 27, 2026 15:51
Copilot AI review requested due to automatic review settings January 28, 2026 08:27
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 support for capturing and processing frontend tool execution results in the AI chat system. The implementation allows the frontend to send tool outputs back to the backend, which are then properly integrated into the chat history for continued conversation flow.

Changes:

  • Added ToolResult type and extraction logic to capture frontend tool execution outputs
  • Refactored tool result handling to use actual frontend results instead of placeholder messages
  • Updated message parsing to support tool-result-only submissions

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/shared/src/lib/ai/chat/index.ts Adds ToolResult type and AIChatMessage union type for structured tool output
packages/server/api/test/unit/mcp/tool-utils.test.ts Comprehensive test coverage for new tool result extraction and mapping utilities
packages/server/api/src/app/ai/mcp/tool-utils.ts Implements tool result extraction from messages and logic to add missing UI tool results to chat history
packages/server/api/src/app/ai/chat/user-message-handler.ts Integrates frontend tool results into chat history processing flow
packages/server/api/src/app/ai/chat/message-parser.ts Updates message parser to handle tool-result-only submissions with dedicated constant
packages/server/api/src/app/ai/chat/chat-request-router.ts Adds routing support for tool-result-only messages and passes frontend results through request pipeline
packages/server/api/src/app/ai/chat/ai-mcp-chat.controller.ts Extracts tool results from incoming messages and handles tool-result-only submissions
packages/react-ui/src/app/features/ai/lib/assistant-ui-chat-hook.ts Updates frontend to use addToolOutput with structured state information instead of addToolResult

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

...aiConfig,
model: currentModel,
};

Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conditional logic for skipping newMessage addition when isToolResultOnly is true lacks explanation. Add a comment explaining why tool-result-only submissions should not add the user message to history (e.g., 'Tool results are added separately to avoid duplicate/placeholder messages in history').

Suggested change
// For tool-result-only submissions, tool outputs are recorded separately,
// so we skip adding a placeholder user message to history to avoid
// duplicate or misleading entries.

Copilot uses AI. Check for mistakes.
@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.

2 participants