Skip to content

Conversation

@qnixsynapse
Copy link
Contributor

@qnixsynapse qnixsynapse commented Oct 24, 2025

Describe Your Changes

  • Added a temporary ToolResult type that mirrors the structure returned by tools (text, image data, URLs, errors).
  • Implemented convertToolPartToApiContentPart to translate each tool output part into the format expected by the OpenAI chat completion API.
  • Updated CompletionMessagesBuilder.addToolMessage to accept a full ToolResult instead of a plain string and to:
    • Detect multimodal content (base64 images, image URLs) and build a structured content array.
    • Properly handle plain‑text results, tool execution errors, and unexpected formats with sensible fallbacks.
    • Cast the final content to any type for the tool role as required by the API.
  • Modified postMessageProcessing to pass the raw tool result (result as ToolResult) to addToolMessage, avoiding premature extraction of only the first text part.
  • Refactored several formatting and type‑annotation sections:
    • Added multiline guard for empty user messages to insert a placeholder.
    • Split the image URL construction into a clearer multiline object.
    • Adjusted method signatures and added minor line‑breaks for readability.
  • Included extensive comments explaining the new logic and edge‑case handling.

These changes enable the chat system to handle richer tool outputs (e.g., images, mixed content) and provide more robust error handling.

Fixes Issues

  • Closes #
  • Closes #

Self Checklist

  • Added relevant comments, esp in complex areas
  • Updated docs (for bug fixes / features)
  • Created issues for follow-up changes or refactoring needed

- Added a temporary `ToolResult` type that mirrors the structure returned by tools (text, image data, URLs, errors).
- Implemented `convertToolPartToApiContentPart` to translate each tool output part into the format expected by the OpenAI chat completion API.
- Updated `CompletionMessagesBuilder.addToolMessage` to accept a full `ToolResult` instead of a plain string and to:
  - Detect multimodal content (base64 images, image URLs) and build a structured `content` array.
  - Properly handle plain‑text results, tool execution errors, and unexpected formats with sensible fallbacks.
  - Cast the final content to `any` for the `tool` role as required by the API.
- Modified `postMessageProcessing` to pass the raw tool result (`result as any`) to `addToolMessage`, avoiding premature extraction of only the first text part.
- Refactored several formatting and type‑annotation sections:
  - Added multiline guard for empty user messages to insert a placeholder.
  - Split the image URL construction into a clearer multiline object.
  - Adjusted method signatures and added minor line‑breaks for readability.
- Included extensive comments explaining the new logic and edge‑case handling.

These changes enable the chat system to handle richer tool outputs (e.g., images, mixed content) and provide more robust error handling.
@urmauur urmauur requested review from dinhlongviolin1 and louis-jan and removed request for louis-jan October 24, 2025 02:58
@thinhlpg thinhlpg requested a review from urmauur October 24, 2025 02:58
@github-actions
Copy link
Contributor

@qnixsynapse qnixsynapse merged commit 2561fcd into dev Oct 24, 2025
37 of 40 checks passed
@qnixsynapse qnixsynapse deleted the fix/mm_mcp branch October 24, 2025 14:45
@github-project-automation github-project-automation bot moved this to QA in Jan Oct 24, 2025
@github-actions github-actions bot added this to the v0.7.3 milestone Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: QA

Development

Successfully merging this pull request may close these issues.

3 participants