Skip to content

[codex] fix chat completions reasoning compatibility#255

Merged
KilimiaoSix merged 1 commit into
qxcnm:mainfrom
KilimiaoSix:codex/chat-completions-reasoning-compat
May 21, 2026
Merged

[codex] fix chat completions reasoning compatibility#255
KilimiaoSix merged 1 commit into
qxcnm:mainfrom
KilimiaoSix:codex/chat-completions-reasoning-compat

Conversation

@KilimiaoSix
Copy link
Copy Markdown
Collaborator

Summary

This PR fixes an OpenAI-compatible Chat Completions bridge issue where CodeXManager can successfully proxy a /v1/chat/completions request through /v1/responses but return an apparently empty assistant message to compatible clients such as Hermes.

The visible symptom is a successful response with empty content when the upstream Responses result is reasoning-only. Hermes already understands reasoning and reasoning_content, but CodeXManager was not mapping Responses reasoning summaries back into those Chat Completions extension fields.

Root Cause

The Chat Completions compatibility path rewrites non-native OpenAI-compatible /v1/chat/completions requests to /v1/responses. The request rewrite only preserved caller-provided reasoning fields and did not request reasoning summaries by default. On the way back, the Responses-to-Chat-Completions conversion only extracted normal answer text, tools, and images, so type: "reasoning" output items and reasoning summary stream events were dropped from the Chat Completions payload.

That made reasoning-only upstream results look like empty assistant responses to clients that rely on Chat Completions semantics.

Changes

  • Default adapted Chat Completions requests to reasoning: { effort: "medium", summary: "auto" } when the caller did not provide reasoning settings.
  • Preserve explicit reasoning_effort while adding summary: "auto".
  • Preserve explicit reasoning objects while adding a missing summary: "auto".
  • Add shared extraction for Responses reasoning summary text from:
    • type: "reasoning" output items
    • summary[].text
    • reasoning summary delta/done stream events
  • Map reasoning summaries to Chat Completions extension fields:
    • streaming: choices[].delta.reasoning and choices[].delta.reasoning_content
    • non-streaming: choices[].message.reasoning and choices[].message.reasoning_content
  • Keep reasoning out of normal content, so user-visible answer text is not polluted.
  • Preserve normal output text, images, and tool call behavior.

Validation

  • cargo test -p codexmanager-service gateway::http_bridge::tests
    • 69 passed
  • cargo test -p codexmanager-service gateway::local_validation::request::tests
    • 36 passed
  • cargo test -p codexmanager-service
    • 950 passed
  • cargo build -p codexmanager-service
    • passed

The branch is based directly on upstream/main and contains only this reasoning compatibility fix.

@KilimiaoSix KilimiaoSix marked this pull request as ready for review May 21, 2026 12:33
@KilimiaoSix KilimiaoSix merged commit 7eefcd5 into qxcnm:main May 21, 2026
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.

1 participant