Skip to content

fix(agents): corrections sent during recovery compaction never reach the model - #185381

Merged
jalehman merged 2 commits into
mainfrom
fix/steered-input-recovery-compaction
Oct 27, 2026
Merged

jalehman merged 2 commits into
mainfrom
fix/steered-input-recovery-compaction

Conversation

@jalehman

Copy link
Copy Markdown
Contributor

Related: #163655, #178985

What Problem This Solves

Fixes: a correction the user sends while a run is doing recovery compaction is accepted (chat.send returns started) but never reaches the model, so the run answers without it.

User Impact

Corrections and follow-up messages steered into a run that hits context overflow and compacts are delivered to that run again, as they were before #163655.

Why This Change Was Made

#163655 hides other turns' live pending inputs from an attempt's model context so announcement runs don't answer a queued chat turn. It samples those inputs once at the attempt boundary and filters them from every later model call. Recovery compaction starts a new attempt while the correction is still live custody, so the correction is sampled as foreign; when chat.send then steers it into that attempt, the agent loop commits it but the frozen filter keeps stripping it.

The attempt's foreign-input filter now treats a user input as its own once this attempt commits it (message_end). Adoption is per idempotency key: inputs the attempt never commits, such as another queued turn, stay hidden. The listener is scoped to the attempt's session and goes away with it.

Accepted edge case: adoption lives for one attempt. If a second recovery attempt starts in the same run before the correction's pending-input owner settles, that boundary could sample it as foreign again. I did not reproduce this; the steering e2e settles the owner (pendingInputs.total is 0). An owner-level handoff (linking the steered input to the run, like promotedOwner) would cover it but needs the Gateway steering path to reach pending-input custody; this keeps the fix inside the existing boundary owner.

Evidence

  • Real-Gateway reproduction from test(e2e): prove the session input lifecycle through a real Gateway #178985 (test/e2e/qa-lab/runtime/gateway-session-steering*.e2e.test.ts, run locally, not committed here): "delivers a correction sent during recovery compaction to the same run once" fails on main with terminal reply Never received: Correction sent during compaction.; passes with this change. All 12 cases in both steering e2e files pass.
  • New regression in attempt-session-boundary.live-input.test.ts: a live input steered into the run after the boundary sampled it reaches the next model call, while another turn's live input stays hidden. Red on base, green here.
  • fix(sessions): preserve active chat input during announcements #163655's coverage stays green: attempt-session-boundary.live-input / .preparation / .orphan / attempt-session-boundary, attempt-session-runtime-context, attempt-session-replay, session-manager-async-message(-custody), session-accessor.pending-inputs* / pending-input-mirror-replay.
  • pnpm check:changed passes (dead-export scan skipped locally; it flags pre-existing extensions/codex exports unrelated to this diff).
  • Local e2e runs needed root tsconfig.json lib ES2024 because of an unrelated Promise.withResolvers declaration-build failure on main; that change is not included.
  • Independent fresh review: no P0/P1. Its suggested negative control was added. Codex autoreview was unavailable on this host (auth route failure).

@clawsweeper

clawsweeper Bot commented Oct 27, 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 agents Agent runtime and tooling size: S labels Oct 27, 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Allows corrections committed by the active attempt to reach subsequent model calls after recovery compaction.

Example: A user sends “Correction sent during compaction.” while recovery compaction is running.

  • Before: The correction is accepted but filtered from the resumed run's model requests.
  • After: The resumed run receives the correction while another turn's queued input stays hidden.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused repair with no definite introduced defect; runtime confidence rests on inspected regression paths and author-reported Gateway execution.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; the author reports successful real-Gateway recovery-compaction steering with a scripted HTTP provider, while inspected committed coverage exercises the real session loop with mocked streaming and no captured execution artifact independently establishes the reported Gateway result.
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 accepted correction sent during recovery compaction can disappear from the active run's model context.
Reason: Restoring accepted correction delivery has clear user value, and the maintainer-authored direction explicitly accepts the bounded attempt-local implementation.

Regression provenance

Regression provenance — verified: source commit a823a52f0806 by Chuanlei Guo; canonical PR #163655 (blame-to-merge-commit).

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a current correction-delivery regression, preserves unrelated input exclusion, and has no definite introduced correctness finding.

Priority: P1
Reviewed head: dabc277a0f72409b5cbc9d29424a9c28bbd8bb76

Before merge

None.

Findings

None.

Agent review details

How this fits together

The embedded runner prepares session history before provider conversion; pending-input custody identifies foreign inputs, and session events identify inputs consumed by the active attempt.

flowchart LR
  A[Accepted correction] --> B[Steering admission]
  B --> C[Active session commit]
  C --> D[Attempt adoption set]
  E[Foreign input snapshot] --> F[Model context filter]
  D --> F
  F --> G[Provider request]
Loading

Technical review

Best possible solution:

Retain per-input adoption in the existing attempt filter while preserving exclusion of unrelated live inputs.

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

The unconditional main-branch filter explains the failure, and the linked Gateway scenario reports matching baseline and revert results; this read-only review executed no target code.

Is this the best way to solve the issue?

The change narrowly updates the existing filter using session-owned consumption events, with a distinct negative control protecting the original announcement-isolation contract.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Foreign live-input exclusion changes intended behavior with a stated reason (a823a52: Prevent announcements from adopting another active request's accepted input during orphan repair or provider conversion.)
  • Session-boundary ownership keeps the original intent (79eb5bd: Consolidate existing session preparation and boundary operations without changing their behavior.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +21, Tests +76. Total +97 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 32 11 +21
Tests 4 79 3 +76
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 111 14 +97

Labels

Label changes:

  • add P1: Current main can silently omit an accepted correction from an active agent run after recovery compaction.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: Current main can silently omit an accepted correction from an active agent run after recovery compaction.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 26, 2026, 11:41 PM ET / October 27, 2026, 03:41 UTC.

@jalehman
jalehman merged commit fc00130 into main Oct 27, 2026
132 of 133 checks passed
@jalehman
jalehman deleted the fix/steered-input-recovery-compaction branch October 27, 2026 04:09
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
roboclaw-bot added a commit that referenced this pull request Oct 27, 2026
Retain the landed preparation adoption owner from #185381 rather than a competing identity-marker exception. Keep the distinct startup regression and preserve upstream Gateway diagnostics.

Co-authored-by: steipete <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant