Skip to content

improve: diagnose rejected ChatGPT conversation continuations - #174972

Closed
xrfc wants to merge 2 commits into
openclaw:mainfrom
xrfc:feat/chatgpt-continuation-diagnostics
Closed

xrfc wants to merge 2 commits into
openclaw:mainfrom
xrfc:feat/chatgpt-continuation-diagnostics

Conversation

@xrfc

@xrfc xrfc commented Oct 17, 2026

Copy link
Copy Markdown

Related: #167667
Follow-up to #174943; independent diagnostic change, not a recovery fix.

What Problem This Solves

Operators cannot tell whether a rejected ChatGPT continuation used a cached response reference, what structural input it carried, or which existing recovery path was selected.

User Impact

Gateway logs now report the actual local transport, presence (not value) of a previous response reference, structural item counts, and the recovery action selected for rejected WebSocket/HTTP requests. Terminal warnings summarize the last local dispatch. No request bodies, message/tool contents, IDs, credentials, or encrypted payloads are copied into these fields.

This does not change provider requests, classification policy, retry limits, tool execution, configuration, or stored history. It does not fix the provider rejection. No migration or restart is introduced.

Why This Change Was Made

The transport owner already knows the exact cached WebSocket payload and existing recovery decision. The diagnostics consume those facts rather than trying to infer them from the conversation. full-input-reconnect records an attempted recovery choice, not success; propagate delegates to the existing outer handler. Dispatch means invocation of the local send interface, not proof of provider receipt. SSE errors after HTTP 200 carry the terminal request summary rather than a separate rejection/recovery event.

The simplify pass keeps one diagnostic sibling and moves the existing timeout/failure categorization helpers unchanged out of the oversized provider. No new state store, dependencies, knobs, or retry owner. Against main: 121 production lines added / 44 removed; 84 test lines added / 4 removed; 14 documentation lines added.

Includes the same two-line CI-only fixture repair as #174943: explain the native-update fixture's existing database-admission isolation and remove its obsolete ledger fingerprint. This is an exact baseline shrink, not a new allowance or a change to mock behavior.

Evidence

  • Final-head focused production-entry-point tests: 13/13 passed, two files; real loopback WebSocket responses cover recovered cached continuation, rejected full-input retry, rejection after events began, and unrelated rejection. Existing SSE coverage verifies the structural HTTP-rejection log and terminal summaries.
  • Boundary assertions verify actual delta-vs-full inputs, preserved completed tool results, bounded recovery request counts, and exclusion of synthetic private fixture content from transport logs. No live provider was called. The new assertions were not separately run on an unpatched baseline.
  • Final focused wrapper wall time 10.94 s, Vitest duration 4.50 s (both files together); streaming test cases totaled ~0.17 s and replay cases ~0.11 s. CI seconds are not yet available.
  • Targeted type-aware lint, formatting, line-cap ratchet (five source files), and diff whitespace checks passed. The repaired mock-export ratchet passed with 9,291 grandfathered factories.
  • A full production typecheck was attempted but blocked before execution by an existing stale build-artifact ownership lock. The lock was not removed or bypassed; no full typecheck pass is claimed.
  • Independent native Codex read-only P0-P2 review found one stale exact log assertion, fixed before publication; no remaining actionable findings. Timeout-helper extraction and CI fixture annotation/ledger shrink also received independent review. This is a native reviewer, not a validated shared-autoreview-helper report: the standalone Codex CLI is unavailable here.
  • No live provider rejection, deployment, Gateway restart, or existing conversation mutation. Broad proof remains for PR CI.
OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs packages/ai/src/providers/openai-chatgpt-responses.replay.test.ts packages/ai/src/providers/openai-chatgpt-responses-streaming.test.ts --maxWorkers=1

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: M labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR adds structural request and recovery-choice diagnostics to ChatGPT Responses rejection logs.

Example: A cached WebSocket continuation containing one completed tool result receives the known replay rejection.

  • Before: Logs identify configured transport as auto without showing whether a cached response reference was dispatched.
  • After: The rejection records actualTransport: websocket, hasPreviousResponseId: true, toolResultItems: 1, and recoveryAction: full-input-reconnect.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch appears focused and correct, but supplied evidence does not clear the external-PR behavior-proof gate, and default logging direction remains an owner choice.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Partial
User problem: Operators investigating rejected continuations cannot distinguish cached references, full input, actual transport, or the recovery choice from existing warnings.
Reason: The diagnostic value is supported by affected-release reports, while the added default warning events need owner direction; broader continuation recovery remains outside this PR.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this PR open: it supplies useful, distinct diagnostics for reported continuation failures, and no introduced correctness defect was found.

Priority: P2
Reviewed head: 7557f309ff5cd63aeb518224334c681dd0d99fea
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should all rejected ChatGPT WebSocket and HTTP requests emit the new structural warning event by default?
  • Recommendation: Approve the structural warnings: Accept the fixed-field rejection events as a focused diagnostic improvement without widening recovery.
  • Why: The reports establish diagnostic value, but no human owner decision approves this added default logging behavior.

Before merge

  • Add real behavior proof - The supplied tests exercise the native transport with real loopback WebSockets and mocked HTTP, but collect diagnostics through a logging spy rather than a shipped Gateway. Provide terminal output or redacted Gateway logs showing a cached continuation rejection selecting full-input-reconnect and a terminal rejection carrying the last dispatched request summary; redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Tests

  • Missing end-to-end proof: Supply running-Gateway output for cached rejection and terminal failure diagnostics; the added assertions also lack a demonstrated base-fail/head-pass run.
Agent review details

How this fits together

The embedded ChatGPT Responses transport converts conversation history into WebSocket or HTTP requests, processes provider events, and reports failures through the existing transport logging host.

flowchart TD
  A[Conversation and completed tool results] --> B[ChatGPT Responses transport]
  B --> C[Cached WebSocket request]
  B --> D[HTTP SSE request]
  C --> E[Existing recovery decision]
  D --> E
  E --> F[Structural diagnostics]
  F --> G[Gateway logs]
Loading

Technical review

Best possible solution:

Keep structural diagnostics in the existing transport owner and preserve the current recovery and privacy boundaries.

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

Source confirms that current-main warnings omit the proposed request-form and recovery-choice facts; the provider rejection itself has affected-release reports but no deterministic current-main reproduction.

Is this the best way to solve the issue?

Recording the actual dispatched request structure at the existing recovery boundary is appropriate and avoids inferring transport state or changing retry policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6c1414454bd2.

Provenance checked

  • Bounded continuation recovery keeps the original intent (c715a8a: Recover explicitly rejected cached continuations once while preserving completed tool results and leaving unsupported paths terminal.)
  • Transport failure privacy and categorization keeps the original intent (6124d47: Diagnose transport failures using local facts without logging provider-controlled text that could contain conversation content.)
  • Request timeout classification keeps the original intent (c20a055: Honor request timeouts and distinguish caller cancellation; the helper is moved without semantic changes.)
  • Native-update fixture isolation keeps the original intent (048cc4e: The native-maintenance fixture isolates database admission while exercising native stop and activation behavior; the patch documents that existing boundary.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c715a8a adds packages/ai/src/providers/openai-chatgpt-responses.ts:434 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c715a8a2fc56; files: packages/ai/src/providers/openai-chatgpt-responses.ts)
  • Vito Cappello: Raw commit 6124d47 adds packages/ai/src/providers/openai-chatgpt-responses.ts:661 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6124d47e046a; files: packages/ai/src/providers/openai-chatgpt-responses.ts)
  • Vincent Koc: Raw commit a54bec7 adds packages/ai/src/providers/openai-chatgpt-responses.ts:337 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a54bec799cdc; files: packages/ai/src/providers/openai-chatgpt-responses.ts)

PR surface

Source +77, Tests +81, Docs +14, Other -1. Total +171 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 121 44 +77
Tests 3 85 4 +81
Docs 1 14 0 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 7 220 49 +171

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The diagnostics help investigate recurring continuation failures without changing request execution or restoring failed conversations.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 16, 2026, 10:21 PM ET / October 17, 2026, 02:21 UTC.

@xrfc

xrfc commented Oct 17, 2026

Copy link
Copy Markdown
Author

Additional real running-Gateway evidence (baseline only)

Read-only inspection of the existing operator Gateway on 2026-10-17 confirmed a real continuation rejection at 07:03:04 UTC. Gateway status reports OpenClaw 2026.10.2; the installed CLI identifies build b8952d4, running on Node 24.19.0 / Linux (WSL2). This is NOT a deployment of this PR head.

Sanitized field excerpts from the Gateway file log, retrieved through the supported logs command (nonessential fields omitted):

2026-10-17T07:03:04.224Z WARN openai-transport
message: ChatGPT Responses stream terminated
api: openai-chatgpt-responses
transport: auto
elapsedMs: 544
stopReason: error
failureKind: provider-failure

2026-10-17T07:03:04.249Z WARN agent/embedded
event: embedded_run_agent_end
isError: true
providerRuntimeFailureKind: unclassified
rawErrorPreview: Codex error: Persisted response contains hosted-tool, compaction, or unverifiable hidden reasoning state that Rustponses cannot replay. Start a new response or use the Python Responses service for this continuation.
user-facing error: OpenClaw could not finish this reply; check Settings / Logs or openclaw logs --follow.

The user-facing error above is paraphrased; the provider rejection and transport fields are extracted from the actual log. Host/account/model identifiers, run/trace/span IDs, local paths and endpoints are omitted. No conversation or tool content is included.

What this establishes: the real Gateway encounters the reported rejection and its terminal warning exposes only configured transport=auto, without the proposed request-form/recovery-choice fields.

What this does NOT establish: actual WebSocket versus HTTP dispatch, presence of a cached response reference, selection or success of full-input-reconnect, or the behavior of this PR in a running Gateway. Those facts cannot be inferred from this baseline log. The running-Gateway proof request and maintainer decision therefore remain open.

Separately, the unchanged PR head 7557f30 was retested today: the two focused replay/streaming files passed 13/13 tests (Vitest duration 5.45 s). These remain in-process transport tests, not Gateway end-to-end evidence.

No additional Gateway was started, no live Gateway was modified/restarted, and no deliberate provider failure was triggered for this capture.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale after 7 days without qualifying human activity.
Without new human activity, Barnacle may close it as not planned 7 days after this message was posted. This is administrative inactivity cleanup, not a claim that the problem is fixed.
A human update restarts the inactivity clock; a new PR head also restarts it. A maintainer can add no-stale for a durable hold, or bad-barnacle to suppress Barnacle. Remove the hold when work can resume.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 26, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

@openclaw-barnacle openclaw-barnacle Bot closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant