Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 22, 2025

This PR ensures the Model Reasoning Effort is correctly passed to OpenRouter for GPT‑5 models and that reasoning content is requested in the stream.

Changes:

  • Set include_reasoning=true for GPT‑5 requests in createMessage and completePrompt (OpenRouterHandler.createMessage(), OpenRouterHandler.completePrompt()).
  • Default GPT‑5 reasoning effort to "medium" when enabled but unspecified, while honoring explicit settings (including "minimal") in OpenRouterHandler.getModel().
  • Added tests asserting:
    • include_reasoning true and reasoning: { effort: "minimal" } are passed for GPT‑5 via OpenRouter (spec).
    • default reasoning effort "medium" is applied when enabled but not specified (spec).

Context:

  • OpenRouter handler previously relied on upstream reasoning resolution. This PR adds GPT‑5–specific handling to guarantee effort is present and reasoning content is included for streaming.

Validation:

  • Unit tests pass for updated OpenRouter behavior.
  • Lint and type checks pass via turborepo pipeline.

Security:

  • No secrets logged. Error handling remains contained.

Important

Enhance OpenRouter integration for GPT-5 by ensuring reasoning efforts are passed and included, with default effort set when unspecified.

  • Behavior:
    • Set include_reasoning=true for GPT-5 requests in OpenRouterHandler.createMessage() and OpenRouterHandler.completePrompt().
    • Default GPT-5 reasoning effort to "medium" when enabled but unspecified in OpenRouterHandler.getModel().
  • Tests:
    • Added tests in openrouter.spec.ts to assert include_reasoning and reasoning effort for GPT-5.
    • Tests for default reasoning effort "medium" when not specified.
  • Context:
    • Previously relied on upstream reasoning resolution; now ensures effort is present and reasoning content is included for streaming.

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

@roomote roomote bot requested review from cte, jr and mrubens as code owners August 22, 2025 15:01
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Aug 22, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

I reviewed my own code and found it suspiciously adequate.

let adjustedParams = params
if (id.startsWith("openai/gpt-5") && !params.reasoning && this.options.enableReasoningEffort !== false) {
const effort = (this.options.reasoningEffort as any) ?? "medium"
adjustedParams = { ...params, reasoning: { effort } as OpenRouterReasoningParams }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this logic potentially redundant? I notice we're adding GPT-5-specific reasoning handling here, but getModelParams() already calls getOpenRouterReasoning() which should handle reasoning parameters. Could we rely solely on the existing getModelParams() flow instead of duplicating the logic?

stream: true,
stream_options: { include_usage: true },
// For GPT-5 via OpenRouter, request reasoning content in the stream explicitly
...(modelId.startsWith("openai/gpt-5") && { include_reasoning: true }),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider extracting this GPT-5 check to a helper function like isGpt5Model(modelId) since the same check appears in both createMessage() (line 125) and completePrompt() (line 233). This would make future updates easier and more maintainable.

const call = (mockCreate as any).mock.calls[0][0]
expect(call.include_reasoning).toBe(true)
expect(call.reasoning).toEqual({ effort: "medium" })
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good test coverage for createMessage()! Should we add a similar test for completePrompt() to verify that include_reasoning: true is also passed for GPT-5 models in that method?

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 22, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Aug 23, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 23, 2025
@daniel-lxs daniel-lxs marked this pull request as draft August 25, 2025 18:55
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Draft / In Progress] in Roo Code Roadmap Aug 25, 2025
@github-project-automation github-project-automation bot moved this from PR [Draft / In Progress] to Done in Roo Code Roadmap Aug 26, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Draft / In Progress size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants