-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
[Bug]: detectCompat in openai-completions.ts misses Xiaomi endpoints for requiresReasoningContentOnAssistantMessages — diverges from openai-completions-compat.ts #91106
Copy link
Copy link
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.Auth, provider routing, model choice, or SecretRef resolution may break.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.Auth, provider routing, model choice, or SecretRef resolution may break.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
openai-completions-compat.tsandopenai-completions.tsdisagree about which endpoints needrequiresReasoningContentOnAssistantMessages. The agent-layer compat covers both DeepSeek and Xiaomi AI Studio endpoints; the provider-layer auto-detect (detectCompat) only covers DeepSeek. Xiaomi multi-turn sessions that go through the provider layer without the agent transport will not inject the required emptyreasoning_contentfield on replayed assistant messages, causing the provider API to reject the request.Steps to reproduce
api: "openai-completions"pointed at a Xiaomi AI Studio (MiModel) endpoint:reasoning_contentfield.Rolling back to route the same endpoint through
openai-transport-stream.ts(i.e., through an agent withuseTransportStream: true) bypasses the bug because the agent layer'sopenai-completions-compat.tscorrectly setsrequiresReasoningContentOnAssistantMessages: trueforendpointClass === "xiaomi-native".Expected behavior
detectCompatinopenai-completions.tsshould returnrequiresReasoningContentOnAssistantMessages: truefor Xiaomi-native endpoints, consistent with the agent-transport layer.Actual behavior
detectCompatinopenai-completions.tsonly returnsrequiresReasoningContentOnAssistantMessages: isDeepSeek. Xiaomi endpoints are not covered.Code pointers (analysis, not observed)
Divergence found at:
src/agents/openai-completions-compat.ts— agent-layer compat auto-detect:where
isXiaomi = endpointClass === "xiaomi-native" || endpointClass === "xai-native".src/llm/providers/openai-completions.ts— provider-layerdetectCompat:isXiaomiis absent.The two files serve different call paths.
openai-completions-compat.tsfeeds the transport-stream layer (src/agents/openai-transport-stream.ts) which our PR #89832 now correctly wires throughgetCompat.openai-completions.ts'sdetectCompatis used when the provider is called without the higher-level transport (e.g., tool-result or completion-only code paths). For Xiaomi endpoints in that lower path, the field remainsfalseand assistant-message replay omitsreasoning_content.The divergence was likely introduced when
isXiaomiwas added toopenai-completions-compat.tswithout a corresponding update todetectCompatinopenai-completions.ts.This pattern mirrors the original
requiresReasoningContentOnAssistantMessagesschema gap fixed in PR #89832 (issue #89660), but at the auto-detection layer rather than the configuration layer.Proposed fix options
Option A (preferred): Add
isXiaomitoopenai-completions.tsdetectCompat, matching the agent-compat logic:Requires importing or replicating the
endpointClass === "xiaomi-native" || "xai-native"check already present inopenai-completions-compat.ts.Option B: Extract a shared
requiresReasoningContent(model)utility used by both files, so the set of affected endpoints stays in one place and can't diverge again.Option C: Document that
detectCompatinopenai-completions.tsintentionally omits Xiaomi (if these endpoints always go through the transport-stream path). Add a test assertion confirming Xiaomi endpoints are never reached through the provider path without the transport-stream intermediary.Analysis derived from static code search; live reproduction with a Xiaomi AI Studio API key was not performed. Root cause confidence: high (direct code comparison); user impact scope: limited to Xiaomi AI Studio endpoints using the
openai-completionsprovider type without the agent transport layer.This issue was investigated by an automated contributor (openclaw-cron). Analysis follows the #89832 fix; the reviewer who merged that PR may have context on the intended call-path separation between
openai-completions-compat.tsandopenai-completions.ts. If the gap is by design, please close with a brief note — it would clarify the architecture for future contributors.