Skip to content

fix(agents): recover sessions after Responses item conflicts - #199757

Merged
steipete merged 6 commits into
mainfrom
steipete/perf-micro-item-conflict-residual-20260919
Nov 15, 2026
Merged

steipete merged 6 commits into
mainfrom
steipete/perf-micro-item-conflict-residual-20260919

Conversation

@steipete

@steipete steipete commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes OpenAI Responses sessions that repeatedly fail with item_conflict until the user compacts or abandons the session.

Team reliability evidence for November 15: 13 request-level failures across five dashboard sessions; four wedged, zero automatic recoveries, up to five hours before abandonment. The earlier count of 30 included duplicate log lines. All affected builds contained #198357. Seven conflicts had no visible precursor, three followed degenerate output, and one each followed a tool error, user interruption, or another conflict; none followed compaction or restart.

User Impact

The Responses transport repairs rejected saved items and retries once automatically. The repair survives subsequent turns and SQLite reloads, including when the retry itself failed. A second rejection surfaces actionable retry, compaction, and model-switch guidance. After visible output, repair is deferred to the next request so tool effects are not repeated.

No configuration, dependency, or database schema changes. Repair removes rejected provider IDs and opaque reasoning/checkpoints from the request projection while preserving conversation text and paired tool results. Healthy sessions retain their existing prefix and continuation.

Why This Change Was Made

Reuse the existing semantic replay recovery and compaction-suppression owner. Re-anchor conflicting tool-call/result IDs together, discard previous_response_id, and persist a repair receipt through transcript sanitization. Preserve that receipt through async clones and both history-normalization and transport filtering boundaries. Log a session-hashed item_conflict_recovery outcome.

The uniqueness mock reproduces an abort exposing an older completed item: losing warm continuation forces cold replay, which reconstructs arguments under the original item ID. Incomplete aborted calls are already filtered; no speculative abort-specific guard was added. This proves the missing general recovery, not the precise server-side mismatch in every production incident.

Production delta is +218 lines (278 added / 60 removed); tests/support net +392. The growth implements bounded recovery, durable outcomes, and demonstrated replay boundaries. Existing storage, retry, projection-cache, and failed-output owners remain authoritative. The parser moved beside its encoder, and its assertion allowance shrank from 7 to 6. No new cache or parallel recovery owner.

Evidence

Final source head: 486e6ca2badaea2d4d8c9572cb3d59e05b68163c. Exact-head CI passed. ClawSweeper final-head review has zero open items and no actionable findings.

  • Exact-base regression: 8 recovery cases fail / 2 abort-filtering controls pass; fixed suite passes all 10. Covers HTTP 400, SSE, WebSocket, standalone provider, degenerate abort → conflict, retry exhaustion, and deferred repair.
  • Final focused run: 206 tests / 7 files / 5 shards pass, including all 14 prefix-stability cases and actual embedded-agent tool execution with SQLite reopening across three turns. The failed-repair reopen case was red before the history fix: 9 requests instead of 8. Empty-error and NO_REPLY receipt regressions were also red.
  • Async-clone, filtered-owner, and delayed-result regressions failed before their respective corrections. Existing failed-output filtering remains in control.
  • Final Chromium 5 browser + 7 end-to-end cases pass; 30 related UI unit tests also passed.
  • Offline compatibility: exact-base transport writes legacy messages through the real SQLite owner; candidate repairs once, saves the receipt, closes/reopens, then continues in one request with an identical repaired prefix. No migration. Synthetic provider; no live-provider or Team deployment claim.
  • Codex autoreview: full candidate and subsequent corrections are scoped-clean P0–P2; final history-normalization review has no accepted/actionable findings. pr-simplify completed.
  • pnpm check:changed was run. The known dead-export main regression reproduces on exact base bdbf30094ec879e410523f95294ff7ff4a9baa4c, introduced by cec47fd13f23 / feat(openclaw-id): name invited members from their email and ask who they are on first visit #198491 (ui/src/lib/openclaw-id/member-welcome.ts). It remains a lead follow-up, not noise or a claimed green check. Final local run completed: every other check passes, including all core/test type graphs, formatting, lint, import cycles, and source guards.
  • Prior head 4cb4d78c642b CI had one gateway WebSocket event timeout. The selected test and full 15-case Bun file pass locally; the full file also passes on the exact main parent. This failure remains unreproduced, not proven inherited or fixed. No CI rerun was requested; the final source head gets fresh CI.

Synthetic scale proof uses a 54.75 GiB SQLite DB, 5,000 session records, 309,410 events, and 62,000 workspace files / 1.116 GB, with no Team data. The ordinary database owner completed integrity/foreign-key checks. APFS host, not btrfs. Eight actual stored histories exercise request preparation; five interleaved A1/A2/B repetitions per timing/allocation mode compare exact base with the reviewed transport implementation:

Per-request owner metric Before After A/A variation
Wall 747.88 µs 748.53 µs (+0.09%) −6.50…+2.84%
CPU 836.16 µs 805.91 µs (−3.62%) −6.11…+5.01%
Sampled allocation 841,415 B 835,730 B (−0.68%) −0.28…+1.32%

All wire hashes match. No speedup claim; measurements are owner stress proof, not end-user latency. Fresh rotating-session allocation confirmation measured 76,504→76,875 B/request (+0.485%, 371 B), with A/A variation −1.078…+0.442%. The final upstream normalization owner measurement (1,000 messages, 2,000 attempts, five A1/A2/B repetitions) measured 47.53→45.79 µs wall, 67.09→66.32 µs CPU, and 52,607→52,491 sampled B/request (−0.22%). Hashes and copy/reuse counts match. Allocation A/A variation was −0.377…+0.279%; host contention made timing controls too noisy for a latency conclusion (wall −83.89…+260.00%, CPU −16.93…+53.29%).

@clawsweeper

clawsweeper Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: L labels Nov 15, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

Please review head 0f58c2680cde771305ed2c32db6baf3cd5491bf2, especially the one-retry budget, persisted recovery marker across transcript sanitization, matching call/result IDs, and avoiding replay after output has started. Focused transport/embedded-agent/prefix/UI proof and Codex autoreview are complete. Performance and exact-head checks remain in progress while the PR is draft.

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. labels Nov 15, 2026
@steipete
steipete marked this pull request as ready for review November 15, 2026 20:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T22:01:07.254962Z 486e6ca New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f58c2680c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +644 to +645
replayPlan.itemRecovery?.owner &&
msg.providerReplay === replayPlan.itemRecovery.owner.providerReplay

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Match recovery receipts across cloned async fragments

When a successfully repaired response emits async tools, agent-stream-response.ts:476–481 structured-clones each committed prefix, including its recovery receipt. The terminal fragment retains another receipt object, and the replay resolver selects that last fragment as the owner. This reference-equality check therefore misses the earlier fragments and reanchors their newly generated tool calls. orderResponsesAsyncToolResults places their results after the terminal fragment, where recovery has been disabled, so calls receive replacement IDs while results retain the original IDs. The next request contains unmatched function outputs and can fail again. Identify the recovery boundary using the durable receipt identity across fragments rather than object identity.

AGENTS.md reference: AGENTS.md:L71-L71

Useful? React with 👍 / 👎.

Comment on lines 639 to +643
for (const msg of replayMessages) {
// The recovery receipt anchors only the rejected past. New output keeps its IDs.
if (
"role" in msg &&
msg.role === "assistant" &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the recovery cutoff when failed owners are filtered

If the repair retry fails without producing content, its empty error message still owns the persisted recovery receipt. On subsequent library requests, the replay plan finds that owner before transformation, but transformMessages drops it through resolveFailedAssistantReplay (transcript-transform.ts:189–199). Consequently, this loop never reaches the owner and never clears recoveryAnchor, even after later requests succeed. Every later assistant output is then treated as rejected history: fresh reasoning is discarded and fresh tool-call IDs are rewritten, preventing normal continuation and repeatedly rebuilding the full history. Preserve the cutoff independently of whether the receipt-bearing message survives transcript filtering.

AGENTS.md reference: AGENTS.md:L71-L71

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Nov 15, 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. 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 Nov 15, 2026
@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Automatically recover Responses item conflicts once and preserve the repaired replay boundary across later turns and session reloads.

Example: Cold replay reconstructs stored tool arguments from { "n": 1 } to {"n":1} under the original provider item ID.

  • Before: The provider rejects the reused identity with item_conflict, and subsequent turns repeat the failure.
  • After: One retry removes rejected provider identities, assigns matching replacement call/result IDs, and records the repair for later requests.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair and regression coverage are convincing, with confidence bounded by production-path harness proof rather than a shipped-entry-point demonstration.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (terminal): Real production transport clients exercise injected item conflicts over loopback HTTP/SSE and WebSocket, and the supplied terminal trace demonstrates recovery followed by SQLite reopening with a stable repaired prefix; this satisfies the internal-recovery boundary allowance, without claiming live-provider recovery.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An existing Responses conversation repeatedly fails with item_conflict instead of recovering on the next turn.
Reason: The maintainer-authored direction addresses observed conversation failures while retaining healthy-session behavior and existing configuration.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a current session-wedging failure. All three prior findings are resolved at the reviewed head, and no new actionable defects were found; exact-head CI remains pending.

Priority: P1
Reviewed head: 486e6ca2badaea2d4d8c9572cb3d59e05b68163c

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Responses transport converts saved conversation messages into provider requests and streams assistant output back to the agent; transcript sanitization and SQLite persistence retain its recovery receipt.

flowchart LR
  A[Saved conversation] --> B[Agent history normalization]
  B --> C[Responses replay projection]
  C --> D[Provider transport]
  D --> E[Conflict recovery]
  E --> C
  E --> F[Persisted recovery receipt]
  F --> A
Loading

Technical review

Best possible solution:

Extend the existing semantic recovery and replay-state owners with one bounded repair that preserves conversation content and durable call/result pairing.

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

The committed loopback regression models immutable provider item identity rejecting reconstructed tool arguments, with reported base failures and head passes; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch repairs the rejected request projection through existing owners, preserves transcript content, and bounds retries before output, making it a focused solution to the demonstrated missing recovery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 29b1f65e7970.

Provenance checked

  • Shared Responses conversion keeps the original intent (17eb646: Consolidate provider and transport replay conversion while preserving their explicit semantic differences.)
  • Complete-stream semantic recovery keeps the original intent (1ff98e5: Recover deferred provider rejections without retrying after committed output or failed lifecycle hooks.)
  • Durable compaction suppression keeps the original intent (47f78a3: Persist route-scoped rejection tombstones so later turns do not replay rejected opaque checkpoints.)
  • Agent-history normalization keeps the original intent (e4da220: Normalize replay content independently of stored transcript presentation; existing failed and silent content filtering remains active.)
  • Item-conflict recovery guidance changes intended behavior with a stated reason (58c1549: Give actionable recovery instructions for unrecovered saved-state conflicts; this PR updates them to reflect automatic recovery.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 1ff98e5 adds packages/ai/src/transports/openai-responses-replay-internal.ts:179 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1ff98e5fbcd9; files: packages/ai/src/transports/openai-responses-replay-internal.ts)
  • Vincent Koc: Raw commit a54bec7 adds packages/ai/src/transports/openai-responses-replay-internal.ts:225 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: a54bec799cdc; files: packages/ai/src/transports/openai-responses-replay-internal.ts)
  • Ayaan Zaidi: Raw commit 77e2261 adds packages/ai/src/transports/openai-responses-replay-internal.ts:196 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 77e2261b573a; files: packages/ai/src/transports/openai-responses-replay-internal.ts)

PR surface

Source +218, Tests +392, Docs +17, Other 0. Total +627 across 21 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 12 278 60 +218
Tests 6 571 179 +392
Docs 2 17 0 +17
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 21 867 240 +627

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +278/-60; tests and support +571/-179 The growth covers bounded recovery, durable receipts, and distinct transport, async, filtering, and reload failures.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit. Replaced prior rating: 🧂 unranked krab.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 session-state: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Reported active conversations repeatedly reject requests and remain unusable without manual recovery or abandonment.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit. Replaced prior rating: 🧂 unranked krab.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-15T21:03:19.507Z sha 96ab001 :: blocked before merge. :: [P1] Match cloned recovery receipts by durable identity | [P2] Preserve the cutoff when transformation drops its owner
  • reviewed 2026-11-15T21:36:18.011Z sha 4cb4d78 :: needs changes before merge. :: [P2] Preserve recovery receipts through agent-history normalization

Reviewed November 15, 2026, 5:02 PM ET / 22:02 UTC (Revision 3).

@steipete

steipete commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Final head: 486e6ca2badaea2d4d8c9572cb3d59e05b68163c. Addressing current review item 1 and retaining the dispositions for all three earlier items:

  1. Current item 1 — history normalization: src/agents/embedded-agent-runner/replay-history.ts:356–364 now preserves a content-free receipt after discarded failed/silent content. The existing replay metadata owner exposes the typed anchor reader at packages/ai/src/transports/openai-responses-compaction-replay.ts:75–83; no second metadata parser or new cache. replay-history.test.ts:141–161 covers empty-error and NO_REPLY rows; both failed before this correction. The actual embedded-agent/SQLite reopen test at embedded-agent-runner.responses-cold-prefix.test.ts:29–233 now includes a failed repair retry: before the fix the next reopened turn repeated the conflict (9 requests instead of 8); with the fix request counts are 3, 5, 8, with exactly two deliberate rejections and no new conflict on the third turn. Normal failed-content filtering stays in place.

Earlier review dispositions, still verified at the final head:

  1. Cloned recovery receipts: packages/ai/src/transports/openai-responses-replay-messages-internal.ts:642–667 now matches the durable anchor rather than object identity. Fresh async fragments keep their original call IDs. An additional reproduced case keeps a delayed old result paired with its repaired call even when it arrives after the boundary; its projection cache key includes the repair anchor. The provider and transport regressions cover early and late results in openai-responses-async-replay.test.ts:315–350.
  2. Filtered failed owners: packages/ai/src/transports/openai-responses-compaction-replay.ts:351–373 keeps a content-free replay boundary independently of the failed output. It uses the existing failed-turn classifier, covering empty, reasoning-only, blank-text, fallback-text, and unfinished-tool receipts; normal filtering still drops unsafe content. No saved transcript is rewritten. The regression at openai-responses-async-replay.test.ts:352 covers all five forms. The first correction handled only empty output; local Codex review caught the missing nonempty forms, and the final correction covers them too.
  3. Stored-data compatibility: an offline two-process proof used exact base bdbf30094ec879e410523f95294ff7ff4a9baa4c to produce a Responses tool call and persist its user/assistant/tool-result messages through the real SQLite transcript owner. The candidate loaded that existing database without migration, repaired its cold replay, persisted the receipt through sanitizeTranscriptMessage, closed the database and transport, then reopened and continued with an identical repaired prefix. No schema/config changes are present. The committed embedded-agent regression additionally executes a real tool and reopens SQLite across three turns; the provider is synthetic, not a live API.

Sanitized terminal trace from the exact-base writer and candidate reader (all fixture content is synthetic):

{"event":"legacy-sqlite-written","messages":3,"recoveryReceipt":false}
{"event":"synthetic-provider-request","request":1,"inputItems":4,"conflict":true,"previousResponse":false}
[responses] item_conflict_recovery sessionHash=sha256:f461625a5dc7 outcome=started
{"event":"synthetic-provider-request","request":2,"inputItems":3,"conflict":false,"previousResponse":false}
[responses] item_conflict_recovery sessionHash=sha256:f461625a5dc7 outcome=recovered
{"event":"synthetic-provider-request","request":3,"inputItems":5,"conflict":false,"previousResponse":false}
{"event":"upgrade-continuation-proven","storedMessages":5,"repairRequests":2,"reloadRequests":1,"prefixStable":true}

Final proof: 206 focused tests / 7 files / 5 shards pass, including all 14 prefix-stability cases and all three embedded SQLite reopen modes. Chromium browser 5 and end-to-end 7 cases pass. Final Codex P0–P2 delta review is scoped-clean. pnpm check:changed completes with every check green except the unchanged main dead-export regression from cec47fd13f23 / #198491, reproduced on exact base bdbf30094ec879e410523f95294ff7ff4a9baa4c. No UI screenshots are offered as Responses proof; the provider is synthetic.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. labels Nov 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d413c371b3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

attempted = true;
const request = await buildRequest({ itemRecovery: anchor });
delete request.previous_response_id;
suppressOpenAIResponsesCompaction(output, model, options, undefined, anchor);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve repair receipts through Gateway history normalization

When a repaired response is a silent NO_REPLY, or the repair retry fails without content, the recovery receipt exists only on that assistant message. In the embedded-agent path, normalizeAssistantReplayMessage in src/agents/embedded-agent-runner/replay-history.ts:264–278 drops those messages before transport conversion, so buildOpenAIResponsesCompactionReplayPlan never sees the receipt. Subsequent turns therefore replay the original conflicting IDs and require another repair instead of retaining the repaired prefix. Unlike the previously reported transport-filtering issue, the fresh evidence here is the Gateway's earlier history-normalization stage, which runs before the newly added synthetic-boundary handling. Preserve the receipt independently of whether its assistant content survives that stage.

AGENTS.md reference: AGENTS.md:L71-L71

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit d1307e6 into main Nov 15, 2026
148 of 149 checks passed
@steipete
steipete deleted the steipete/perf-micro-item-conflict-residual-20260919 branch November 15, 2026 22:17
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Patrick-Erichsen added a commit that referenced this pull request Nov 16, 2026
…199846)

#199757 changed the item-conflict recovery message shown to users but left
this suite asserting the previous wording, so the test fails on main and on
any PR whose changed lanes include auto-reply.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 16, 2026
…w#199757)

* fix(agents): recover saved Responses item conflicts automatically

* chore: shrink assertion allowance after moving Responses parser

* perf(ai): preserve normal Responses projection keys outside recovery

* fix(ai): preserve Responses recovery boundaries across async replay

* fix(ai): validate recovery receipts in the replay state owner

* fix: preserve Responses recovery after failed retries
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 16, 2026
…penclaw#199846)

openclaw#199757 changed the item-conflict recovery message shown to users but left
this suite asserting the previous wording, so the test fails on main and on
any PR whose changed lanes include auto-reply.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. docs Improvements or additions to documentation merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant