Skip to content

Bug: native Codex responses backend returns valid SSE without content-type, causing invalid_provider_content_type for openai/gpt-5.5 #91662

Closed

Description

@SeeUCelestial

Environment

  • OpenClaw: 2026.6.1 (2e08f0f)
  • OS: macOS Darwin 25.3.0 arm64
  • Node: v25.9.0
  • Auth: OpenAI/Codex OAuth profile
  • Model: openai/gpt-5.5
  • Provider API: openai-chatgpt-responses
  • Auth route: provider=openai, runtime=codex, authProvider=openai

Summary

After upgrading to OpenClaw 2026.6.1, openai/gpt-5.5 through Codex OAuth failed in the native OpenClaw runtime before producing content.

The failure was not an auth/account/network issue. A direct minimal request to the native Codex backend succeeded and returned a valid SSE stream, but the response had no content-type header. OpenClaw then rejected the response with invalid_provider_content_type.

Observed error

OpenClaw agent command failed with:

GatewayClientRequestError: FailoverError: LLM request failed: network connection error

Gateway log contained:

[responses] error provider=openai api=openai-chatgpt-responses model=gpt-5.5
causeName=ProviderHttpError causeCode=invalid_provider_content_type
message=Connection error.

Investigation

A direct request to:

https://chatgpt.com/backend-api/codex/responses

using the same OAuth profile/token path returned HTTP 200 and valid SSE events, including:

response.created
response.output_text.delta
response.completed

The output text was OK.

However:

response.headers.get("content-type")

was null.

So the backend response was usable, but OpenClaw's transport rejected it before parsing the stream.

Local workaround that fixed it

In the installed bundle:

dist/openai-transport-stream-*.js

I wrapped successful native Codex backend responses that have a body but no content-type:

if (
  usesNativeOpenAICodexResponsesBackend(model) &&
  response.ok &&
  response.body &&
  !response.headers.get("content-type")
) {
  const headers = new Headers(response.headers);
  headers.set("content-type", "text/event-stream; charset=utf-8");
  response = new Response(response.body, {
    status: response.status,
    statusText: response.statusText,
    headers
  });
}

After restarting the gateway, the same openclaw agent run succeeded with:

status: ok
model: gpt-5.5
agentHarnessId: openclaw
runner: embedded
fallbackUsed: false

Expected behavior

For the native Codex responses backend, if the response is HTTP OK, has a readable body, and is missing content-type, OpenClaw should either:

  1. tolerate the missing header and parse it as SSE, or
  2. identify this backend-specific case before raising invalid_provider_content_type.

This should be scoped only to the native Codex backend path, not generic OpenAI API responses.

Activity

  1. clawsweeper commented on Jun 9, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

    Close as implemented on current main: the reported v2026.6.1 failure is real in the release tag, but main now normalizes successful missing-content-type streamed OpenAI/Codex responses after sniffing the body and has targeted regression coverage; the fix has not shipped in a release yet.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review details

    Best possible solution:

    Keep the current main transport normalization and let the next release carry it; no separate OpenClaw source change remains for this issue.

    Do we have a high-confidence way to reproduce the issue?

    Yes from source against v2026.6.1: the release tag rejects OK streamed responses with missing content-type before parsing. Current main no longer has that failure path, so this is not a current-main failing repro.

    Is this the best way to solve the issue?

    Yes. The main fix is at the shared guarded fetch boundary, normalizes only successful streamed OpenAI-compatible responses after body sniffing, and still rejects HTML or unknown bodies.

    Security review:

    Security review: No PR patch is under review, and the issue is not a security-sensitive report.

    AGENTS.md: found and applied where relevant.

    What I checked:

    • Current source handles missing content-type streams: Current main classifies a successful streamed OpenAI-compatible response body when content-type is missing, then wraps SSE bodies with text/event-stream before the SDK parses them. (src/agents/provider-transport-fetch.ts:304, 257b251e2690)
    • Current fetch path applies the normalization before returning the response: buildGuardedModelFetch checks streaming request bodies and calls normalizeOpenAISdkStreamContentType before building the managed response. (src/agents/provider-transport-fetch.ts:841, 257b251e2690)
    • Regression coverage exists on main: The tests cover missing content-type SSE from chatgpt.com/backend-api/codex/responses, open streams, split SSE prefixes, JSON synthesis, and HTML rejection. (src/agents/provider-transport-fetch.test.ts:245, 257b251e2690)
    • Latest release still has the reported failure mode: The v2026.6.1 tag uses assertOpenAISdkStreamContentType and throws invalid_provider_content_type whenever an OK streamed response has a missing content-type. (src/agents/provider-transport-fetch.ts:231, 2e08f0f4221f)
    • Git history ties the implementation to main: git blame ties the normalization block and tests to 82afc46, committed 2026-06-09T11:16:15+09:00. (src/agents/provider-transport-fetch.ts:304, 82afc4678ace)
    • Release provenance is main-only: git tag --contains produced no release tag for 82afc46, while git branch --contains showed main, so the fix is present on current main but not shipped in v2026.6.1. (82afc4678ace)

    Likely related people:

    • harjoth: Line blame and the -S history for the current normalization/tests point to commit 82afc46. (role: recent area contributor; confidence: high; commits: 82afc4678ace; files: src/agents/provider-transport-fetch.ts, src/agents/provider-transport-fetch.test.ts)
    • Vincent Koc: Recent main history on the same provider transport/Responses files includes adjacent OpenAI-compatible Responses fixes, and the v2026.6.1 tag provenance is tied to this release path. (role: recent responses transport contributor; confidence: medium; commits: 1727ec7b2dca, b08e1109c67e, 2e08f0f4221f; files: src/agents/provider-transport-fetch.ts, src/llm/providers/openai-chatgpt-responses.ts)

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 257b251e2690; fix evidence: commit 82afc4678ace, main fix timestamp 2026-06-09T11:16:15+09:00.

  2. added
    P2Normal backlog priority with limited blast radius.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    on Jun 9, 2026
  3. locked as resolved and limited conversation to collaborators on Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions