-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Refactor duplicate Codex Responses paths for agent turns and llm.complete #90193
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.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.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.maintainerMaintainer-authored PRMaintainer-authored PR
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.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.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.maintainerMaintainer-authored PRMaintainer-authored PR
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
OpenClaw currently has two divergent Codex Responses paths that both reach the ChatGPT Codex Responses API but implement request/stream handling differently:
openai-chatgpt-responsesimplementation insrc/llm/providers/openai-chatgpt-responses.ts.llm.complete, rewrite Codex models throughopenclaw-openai-responses-transportviasrc/agents/simple-completion-transport.tsand then use the OpenAI SDK transport insrc/agents/openai-transport-stream.ts.This duplication recently caused a behavior split: normal Codex agent turns continued to work, while plugin
llm.completecalls could fail on valid ChatGPT Codex HTTP 200 streams with missingcontent-typebecause the generic transport path had stricter header validation.Why This Matters
The two paths are not merely cosmetic alternatives. They encode different assumptions about:
When those assumptions diverge, fixes in one path may not protect the other. The current incident is a concrete example: the provider-owned Codex path tolerated the observed upstream response shape, while the simple-completion transport path rejected it before the SDK could parse the stream.
Current Evidence
Relevant paths:
src/llm/providers/openai-chatgpt-responses.tshttps://chatgpt.com/backend-api/codex/responsessrc/agents/simple-completion-transport.tsopenai+openai-chatgpt-responsessimple completions toopenclaw-openai-responses-transportsrc/agents/openai-transport-stream.tsbuildGuardedModelFetch(model)as the SDK fetch implementationsrc/agents/provider-transport-fetch.tsProposed Refactor Direction
Do not attempt this as part of a narrow incident fix. The immediate production fix should remain scoped to the broken validation behavior.
For follow-up refactoring, investigate one of these shapes:
llm.completeshare URL/header/validation/SSE contracts.Acceptance Criteria
llm.completeCodex calls share the same documented response validation contract.content-type, explicit HTML, valid SSE, and valid JSON fallback behavior where applicable.