Skip to content

fix(console): strip reasoning from oa-compatible history#28308

Open
JGoP-L wants to merge 4 commits into
anomalyco:devfrom
JGoP-L:fix-27852-oa-compatible-reasoning
Open

fix(console): strip reasoning from oa-compatible history#28308
JGoP-L wants to merge 4 commits into
anomalyco:devfrom
JGoP-L:fix-27852-oa-compatible-reasoning

Conversation

@JGoP-L
Copy link
Copy Markdown

@JGoP-L JGoP-L commented May 19, 2026

Issue for this PR

Closes #27852

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Some OpenAI-compatible providers reject non-standard fields inside chat history messages. In the reported case, messages[].reasoning was forwarded to OpenCode Go for kimi-k2.6, which caused a 400 response because the gateway rejected that field.

This change removes only the non-standard reasoning field from outgoing OpenAI-compatible chat history messages before the provider request is sent.

It does not remove top-level reasoning settings, and it does not remove provider-specific content fields such as reasoning_content.

How did you verify your code works?

Added a regression test for the OpenAI-compatible request path and ran:

cd packages/console/app
bun test

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Copilot AI review requested due to automatic review settings May 19, 2026 07:34
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels May 19, 2026
Copy link
Copy Markdown
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

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds request sanitization for the OpenAI-compatible provider by removing non-standard reasoning fields from chat messages, along with a regression test to ensure outgoing requests don’t include those fields.

Changes:

  • Sanitize outgoing messages by stripping the non-standard reasoning property before sending requests via oaCompatHelper.modifyBody.
  • Add a Bun test validating that reasoning is removed from messages on same-format conversions.

Reviewed changes

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

File Description
packages/console/app/src/routes/zen/util/provider/openai-compatible.ts Sanitize body.messages by removing reasoning before building the outgoing request body.
packages/console/app/test/openai-compatible.test.ts Adds coverage to ensure the OpenAI-compatible request path strips reasoning from chat history.

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

Comment on lines +84 to +91
function stripNonStandardMessageFields(body: Record<string, any>) {
if (!Array.isArray(body.messages)) return body
return {
...body,
messages: body.messages.map((message) => {
if (!message || typeof message !== "object") return message
const { reasoning: _reasoning, ...sanitized } = message
return sanitized
Comment on lines +84 to +94
function stripNonStandardMessageFields(body: Record<string, any>) {
if (!Array.isArray(body.messages)) return body
return {
...body,
messages: body.messages.map((message) => {
if (!message || typeof message !== "object") return message
const { reasoning: _reasoning, ...sanitized } = message
return sanitized
}),
}
}
Comment on lines 33 to 39
modifyBody: (body: Record<string, any>, _workspaceID?: string) => {
const sanitized = stripNonStandardMessageFields(body)
return {
...body,
...(body.stream ? { stream_options: { include_usage: true } } : {}),
...sanitized,
...(sanitized.stream ? { stream_options: { include_usage: true } } : {}),
}
},
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

Bug: 400 Error (Extra inputs not permitted) when sending 'reasoning' field in chat history for kimi-k2.6

2 participants