Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Dec 23, 2025

Summary

Standardizes the environment_details merging behavior across all OpenAI-compatible providers. This ensures that text content after tool_result blocks (like environment_details) is merged into the last tool message instead of creating separate user messages.

This behavior was previously implemented for DeepSeek (r1-format.ts) and Z.ai (zai-format.ts) providers but not for the other 16 OpenAI-compatible providers.

Changes

  • Added mergeToolResultText option to convertToOpenAiMessages() in openai-format.ts
  • Updated ConvertToOpenAiMessagesOptions interface with the new option
  • Enabled mergeToolResultText: true in all 16 OpenAI-compatible providers:
    • base-openai-compatible-provider.ts
    • roo.ts, openrouter.ts, openai.ts (4 places)
    • deepinfra.ts, lm-studio.ts, unbound.ts, qwen-code.ts
    • cerebras.ts, vercel-ai-gateway.ts, featherless.ts, xai.ts
    • requesty.ts, lite-llm.ts, huggingface.ts, chutes.ts
  • Added 6 unit tests covering the new behavior

Why This Matters

When using native tool calling, the environment_details text that follows tool results was being sent as a separate user message. Some models have issues with user messages interrupting tool call sequences, which can:

  • Cause reasoning models to drop their reasoning context
  • Lead to less coherent responses in multi-turn tool conversations

By merging this text into the last tool message, we maintain a cleaner message flow that works better across all model types.


Important

Standardizes environment_details merging for all OpenAI-compatible providers by adding mergeToolResultText option to convertToOpenAiMessages() and enabling it across 16 providers.

  • Behavior:
    • Adds mergeToolResultText option to convertToOpenAiMessages() in openai-format.ts to merge environment_details into the last tool message.
    • Enables mergeToolResultText: true for 16 OpenAI-compatible providers, including base-openai-compatible-provider.ts, roo.ts, and openrouter.ts.
    • Prevents reasoning models from dropping context by maintaining a cleaner message flow.
  • Tests:
    • Adds 6 unit tests in openai-format.spec.ts to cover new merging behavior.

This description was created by Ellipsis for 7e9bdc0. You can customize this summary. It will automatically update as commits are pushed.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Enhancement New feature or request labels Dec 23, 2025
@roomote
Copy link
Contributor

roomote bot commented Dec 23, 2025

Oroocle Clock   See task on Roo Cloud

Review complete. No issues found.

  • No issues flagged
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 23, 2025
Add mergeToolResultText option to convertToOpenAiMessages() that merges text content
after tool_result blocks into the last tool message instead of creating separate
user messages. Enable this for the Roo Code Cloud provider.

This improves compatibility with reasoning/thinking models (like DeepSeek-reasoner,
GLM-4.7, etc.) where a user message after tool results causes the model to drop
all previous reasoning_content.

- Add mergeToolResultText option to ConvertToOpenAiMessagesOptions interface
- Implement merging logic in openai-format.ts with proper edge case handling
- Enable mergeToolResultText: true in roo.ts provider
- Add 6 unit tests covering the new behavior
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 23, 2025
…iders

Enable mergeToolResultText option for the remaining 15 OpenAI-compatible providers
(excluding Roo Code Cloud which is in PR #10301):

- base-openai-compatible-provider.ts
- openrouter.ts, openai.ts (4 places)
- deepinfra.ts, lm-studio.ts, unbound.ts, qwen-code.ts
- cerebras.ts, vercel-ai-gateway.ts, featherless.ts, xai.ts
- requesty.ts, lite-llm.ts, huggingface.ts, chutes.ts

This follows PR #10301 which introduces the mergeToolResultText option and
enables it for the Roo Code Cloud provider. Together they standardize the
environment_details merging behavior across all OpenAI-compatible providers.

Depends on: #10301
@hannesrudolph hannesrudolph force-pushed the feat/merge-tool-result-text-all-providers branch from 950baf3 to 7e9bdc0 Compare December 23, 2025 07:43
@hannesrudolph
Copy link
Collaborator Author

⚠️ PR Updated - Now Depends on #10301

This PR has been rebased and restructured for a staged rollout:

Changes

Dependency

This PR now depends on #10301 which introduces the mergeToolResultText option and enables it for the Roo Code Cloud provider first.

Merge Order

  1. Merge feat: enable mergeToolResultText for Roo Code Cloud provider #10301 first (Roo Code Cloud provider + core implementation + tests)
  2. Then merge this PR (remaining 15 providers)

This staged approach reduces risk by rolling out to Roo Code Cloud first before enabling across all providers.

@hannesrudolph hannesrudolph merged commit ded6486 into main Dec 23, 2025
10 checks passed
@hannesrudolph hannesrudolph deleted the feat/merge-tool-result-text-all-providers branch December 23, 2025 21:19
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Dec 23, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants