Skip to content

[Bug]: ChatGPT Responses websocket hits the 60-minute connection limit mid-stream; turn fails with no reconnect or model fallback #166708

Closed

Description

@Jackten

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

On the openai-chatgpt-responses transport, a turn that is mid-stream when the reused Responses websocket hits OpenAI's 60-minute connection limit fails outright: there is no reconnect/retry, no model failover, and the user gets "⚠️ Agent run failed".

Steps to reproduce

  1. Run an agent on openai/gpt-6.1-sol through the ChatGPT/Codex subscription route (openai-chatgpt-responses, transport: auto → websocket) with a fallback model configured.
  2. Keep one session busy with a long agentic turn (in our case a 23-minute, 30-tool-call turn) so the session websocket is reused across requests.
  3. Observe the stream end with websocket_connection_limit_reached ("Responses websocket connection limit reached (60 minutes)") after message streaming has started.

NOT_ENOUGH_INFO for a shorter deterministic repro; this is one observed occurrence.

Expected behavior

The connection-limit error is recoverable by definition ("Create a new websocket connection to continue"). The transport already retries it once when it arrives before the stream starts (connectionLimitBeforeStart in packages/ai/src/providers/openai-chatgpt-responses.ts). The same should happen after the stream starts: open a new socket and replay/continue, or at least classify the failure so model fallback runs.

Actual behavior

  • openai-transport: ChatGPT Responses stream terminated with elapsedMs=1338440, failureKind=provider-failure.
  • The run ended with isError=true, failoverReason=null, providerRuntimeFailureKind=unclassified, raw error Codex error: Responses websocket connection limit reached (60 minutes). Create a new websocket connection to continue.
  • The configured fallback model was not tried, and the turn's work was lost.

Code reading (inference, not traced at runtime): connectionLimitBeforeStart is !websocketStarted && isWebSocketConnectionLimitReachedError(error), so a mid-stream limit falls through to the generic failure. Cached sockets are reused while younger than SESSION_WEBSOCKET_MAX_AGE_MS (55 min), but that age is only checked when the socket is acquired. A request that starts on a ~40–55-minute-old socket and streams long enough will cross 60 minutes. Same logic on main at cbfbdc8.

OpenClaw version

2026.9.8 (d22bef1)

Operating system

macOS (Darwin 27.0.0, arm64)

Install method

git checkout, source build, launchd gateway

Model

openai/gpt-6.1-sol (thinking high)

Provider / routing chain

openclaw -> openai-chatgpt-responses (ChatGPT subscription OAuth, websocket) -> OpenAI

Additional provider/model setup details

Agent fallbacks: deepseek/deepseek-v4-flash. It was never attempted for this failure.

Logs

2026-10-07T16:21:51.725Z WARN openai-transport {"provider":"openai","api":"openai-chatgpt-responses","model":"gpt-6.1-sol","transport":"auto","elapsedMs":1338440,"stopReason":"error","failureKind":"provider-failure"} ChatGPT Responses stream terminated
2026-10-07T16:21:51.729Z WARN embedded run agent end {"isError":true,"error":"⚠️ Agent run failed (model: openai/gpt-6.1-sol).","failoverReason":null,"provider":"openai","rawErrorPreview":"Codex error: Responses websocket connection limit reached (60 minutes). Create a new websocket connection to continue.","providerRuntimeFailureKind":"unclassified"}

Screenshots, recordings, and evidence

NOT_ENOUGH_INFO

Impact and severity

  • Affected: subscription-route OpenAI agents with long agentic turns (WhatsApp group session here)
  • Severity: blocks workflow. 23 minutes of tool work were discarded, and a queued human message waited behind it.
  • Frequency: observed once on 2026-10-07
  • Consequence: failed turn, no reply, no fallback

Additional information

Related but different: #122717 / #122727 (missing-response recovery).

Activity

  1. added
    P1
    clawsweeper:fix-shape-clear
    clawsweeper:queueable-fix
    clawsweeper:source-repro
    impact:auth-provider
    impact:message-loss
    issue-rating: 🦞 diamond lobster
    no-stale
    on Oct 7, 2026
  2. clawsweeper commented on Oct 7, 2026

    @clawsweeper
    Contributor

    Codex review: this still needs some work. Reviewed October 7, 2026, 3:28 PM ET / 19:28 UTC.

    Summary
    Current main still excludes mid-stream connection-limit errors from transport recovery, and the OpenAI provider does not classify that code for fallback. The earlier direct API-key fix does not cover this subscription path; no open PR was found owning the specific repair.

    Reproducibility: yes. at the source boundary: emit a normal Responses event followed by the structured connection-limit error through the subscription WebSocket stream. Current code then skips transport recovery; no runtime reproduction or tests were executed during this read-only review.

    Next step
    The exact provider failure has a narrow source-proven classification gap and an existing recovery owner; establish a failing regression before implementing a focused repair.

    Review details

    Best possible solution:

    Treat subscription connection expiry as a transient failure, reconnect through bounded transcript recovery, and allow configured fallback only where existing replay-safety rules permit it.

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

    Yes, at the source boundary: emit a normal Responses event followed by the structured connection-limit error through the subscription WebSocket stream. Current code then skips transport recovery; no runtime reproduction or tests were executed during this read-only review.

    Is this the best way to solve the issue?

    Blind post-stream replay is not the best repair. The existing runner can continue the saved transcript with bounded recovery while preserving completed work and restricting model fallback to replay-safe attempts.

    AGENTS.md: found and applied where relevant.

    Codex review notes: model internal, reasoning medium; reviewed against 030003c127f8.

    Label changes

    Label changes:

    • add P1: A reported long-running agent turn fails without a reply or eligible recovery, and current source supports the failure mechanism.
    • add impact:message-loss: The reported channel turn ends with an agent failure instead of completing its reply.
    • add impact:auth-provider: The defect is in ChatGPT subscription transport failure classification and model recovery.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

    Label justifications:

    • P1: A reported long-running agent turn fails without a reply or eligible recovery, and current source supports the failure mechanism.
    • impact:message-loss: The reported channel turn ends with an agent failure instead of completing its reply.
    • impact:auth-provider: The defect is in ChatGPT subscription transport failure classification and model recovery.
    Evidence reviewed

    Acceptance criteria:

    • pnpm test packages/ai/src/providers/openai-chatgpt-responses.test.ts --maxWorkers=1
    • pnpm test src/agents/embedded-agent-runner/run/attempt-recovery.test.ts src/agents/embedded-agent-runner/run/assistant-failure.test.ts --maxWorkers=1
    • pnpm test extensions/openai/openai-provider.test.ts --maxWorkers=1
    • git diff --check

    What I checked:

    • Current-main recovery gap: The connection-limit retry requires !websocketStarted. Once a provider event has started the stream, CodexApiError takes the non-transport throw branch before provider_transport_failure diagnostics and SSE fallback handling. (packages/ai/src/providers/openai-chatgpt-responses.ts:412, 030003c127f8)
    • Connection lifetime permits the reported trigger: Cached connections expire at 55 minutes, but acquisition checks that age before a request and then leases the socket. No active-stream age rotation exists. A request beginning below that threshold can cross the reported provider limit; processWebSocketStream already clears continuation and closes the failed socket. (packages/ai/src/providers/openai-chatgpt-responses.ts:1025, 030003c127f8)
    • Missing provider classification: mapCodexEvents preserves websocket_connection_limit_reached as CodexApiError.code, but the provider classification hook maps only SERVER_ERROR and INSUFFICIENT_QUOTA. The shared transient-network policy also lacks the connection-limit code and reported message. (extensions/openai/openai-provider.ts:91, 030003c127f8)
    • Existing safe recovery owner: The runner already performs bounded transient recovery through continueFromCurrentTranscript, including partial output and uncertain effects. Its fallback eligibility remains tied to currentAttemptReplaySafe. This supplies a repair path without adding blind post-stream request replay or relaxing side-effect safeguards. (src/agents/embedded-agent-runner/run/attempt-recovery.ts:385, 030003c127f8)
    • Existing behavior contract and regression gap: Model-failover documentation promises bounded same-model recovery preserving transcript and completed work. The transport's existing connection-limit test injects an error before any start event, and its age-rotation test checks acquisition at 56 minutes; neither exercises expiry after streaming starts. (packages/ai/src/providers/openai-chatgpt-responses.test.ts:207, 030003c127f8)
    • Latest-release comparison: Reading the transport at v2026.9.8 confirms the same !websocketStarted connection-limit gate and early non-transport throw. The reported behavior is not repaired in either the supplied latest release or reviewed main. (packages/ai/src/providers/openai-chatgpt-responses.ts:387, fc23bc864e45)

    Likely related people:

    • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
    • VACInc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  3. clawsweeper commented on Oct 7, 2026

    @clawsweeper
    Contributor

    🦞⚠️
    Automatic implementation stopped before completion.
    Reason: The automatic implementation worker stopped before all deterministic gates completed. Open the workflow run for the exact blocker.
    Worker: https://github.com/openclaw/clawsweeper/actions/runs/37674954566

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

    P1clawsweeper:fix-shape-clearclawsweeper:queueable-fixclawsweeper:source-reproimpact:auth-providerimpact:message-lossissue-rating: 🦞 diamond lobsterno-stale

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions