Skip to content

fix(sessions): preserve active chat input during announcements - #163655

Merged
steipete merged 7 commits into
openclaw:mainfrom
chuanleiguo:fix/foreign-live-input-custody
Oct 25, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
chuanleiguo:fix/foreign-live-input-custody

Conversation

@chuanleiguo

@chuanleiguo chuanleiguo commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #165500

What Problem This Solves

Fixes announcements adopting another active request's accepted input as an orphan, changing the transcript and including that input in the announcement's model context.

User Impact

Background announcements leave active user input available for its original request, including collected inputs and committed inputs resumed after a restart. The original request can continue with its input exactly once.

Why This Change Was Made

Transcript shape cannot distinguish an abandoned user turn from input that another request still owns. The attempt boundary now consults the existing input-custody owner, follows committed collect promotion, and excludes foreign live inputs from orphan repair and model context. It samples custody around transcript reload and keeps the resulting exclusions fixed for the attempt.

Committed replay now uses the existing registered-owner lifecycle while preserving its queued receipt and canonical committed message. Execution permission remains independently checked; revoking execution does not give an unrelated announcement custody of accepted input.

Thanks @chuanleiguo (Chuanlei Guo) for the original fix. The revision removes asynchronous profile-discovery machinery and reduces the patch from 1,506 to 1,038 changed lines: production +278/-79, tests and routing +602/-75, documentation +4. The remaining production growth connects existing custody, transcript promotion, replay, and attempt preparation without adding persistent state.

Evidence

  • Regression on pinned main 96825de52d58: 3 failed / 1 passed. The failing cases expose foreign user text in announcement/provider context; the excluded-input control passes. The initial unrouted run failed before the product boundary and is recorded separately as a setup failure. Candidate run on the same pinned base: 126 tests passed across 10 files, including the three previously failing behaviors and late collect promotion.
  • Focused coverage passed: announcement context and original continuation, late collect promotion, source settlement, committed replay, database aliases, incognito input, first-turn preparation, and all 11 prompt-prefix stability tests.
  • Final integration: merged pinned main 3636968cb1bb without changing any of the 17 candidate files. Replayed the boundary and custody suites against the integrated tree: 7 passed in 307.19 seconds. The final correction also integrates pinned main ebbe13ef1cb8, including the existing transcript-context module extraction. The final two focused tests pass on that integrated tree (151.23 seconds including worker setup and cleanup).
  • Formatting: passed for all 17 changed TypeScript/JavaScript files. Targeted type-aware lint passed for 16 changed TypeScript files; documentation lint passed. The changed-file dry run selected broad repository gates, which are left to PR CI.
  • Independent Codex review: full repair and both CI correction deltas scoped-clean at P2, with no actionable findings. The final test correction uses the established turn-mismatch classifier and proves zero provider calls, unchanged existing transcript entries, and the replacement user remaining the sole active user.
  • Historical synthetic Gateway/HTTP proof: fix(sessions): preserve active chat input during announcements #163655 (comment). This evidence is from an earlier revision and is not a current-head live result.
  • No fresh Gateway or real-provider live run: adapting the historical fixture would require a new harness; the current revision uses focused production-boundary regression tests. External channel round trips were not available in this environment.
  • CI correction: run 40163419032 exposed a shared TS2345 error in physical read-target preparation. The captured session key is now normalized once and supplied to the existing target owner. pnpm tsgo:core, targeted lint/format, and all five physical-target regressions pass (333.63 seconds including worker setup/cleanup).
  • Test-only CI correction: run 40164514624 found an overly generic test message type and a stale replay-error expectation. The fixtures now use PersistedUserTurnMessage and the existing mismatch classifier. Both focused regressions and the affected test TypeScript project pass; production custody checks remain unchanged. Normal thinking/error transcript suffixes remain allowed.
  • Exact-head PR CI: run 40165903771 at aa87345ebf628a58ff1457322c3a1da4dc626b64 is GREEN, with zero pending checks. Full production/test types, lint, runtime checks, and all PostgreSQL conformance shards passed. Final ClawSweeper review found no actionable code issues; it retains the historical-only Gateway proof limitation described above.

@clawsweeper

clawsweeper Bot commented Oct 2, 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.

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR prevents announcements from adopting or exposing accepted input that another active request still owns.

Example: A user submits “queued user request” before a same-session child-result announcement runs.

  • Before: The announcement can include that input in its provider request and interfere with the original continuation.
  • After: Repeated announcements omit the protected input, while its original request can continue with one canonical copy.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation is coherent and the previous finding is resolved, but historical runtime evidence does not establish the revised behavior.
Proof confidence 🦪 silver shellfish (2/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: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An announcement can take another active request’s accepted input into its own model context and disrupt the original request.
Reason: The source-backed defect has a bounded repair, and the current maintainer-contributed revision retains existing custody, persistence, and execution owners without adding configuration or public API.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR: it addresses a concrete input-custody defect still present on current main, and the previous replay-coverage finding is fixed; no new actionable defect was found.

Priority: P2
Reviewed head: aa87345ebf628a58ff1457322c3a1da4dc626b64

Before merge

  • Add real behavior proof - The contributor’s historical DeepSeek observations and authenticated Gateway/HTTP fixture exercise earlier custody implementations; the body explicitly reports no fresh Gateway run for the revised discovery, fixed sampling, and registered committed-replay path. Supply redacted terminal output or logs through an isolated shipped Gateway showing protected direct and collected input omitted from repeated announcements, the original committed request continuing once after restart, and cancelled or revoked input producing no provider request; redact API keys, IPs, 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.

Findings

None.

Tests

  • Missing end-to-end proof: The revised custody implementation lacks a supplied Gateway run covering repeated announcement isolation, collected input, and once-only committed continuation after restart.
Agent review details

How this fits together

The pending-input owner tracks accepted request custody; embedded session preparation uses those facts to protect transcript entries and filter the messages sent to the model.

flowchart LR
  A[Accepted chat input] --> B[Pending input custody]
  B --> C[Canonical transcript]
  B --> D[Attempt preparation]
  C --> D
  D --> E[Announcement context]
  D --> F[Original request continuation]
  E --> G[Model provider]
  F --> G
Loading

Technical review

Best possible solution:

Use the existing pending-input registry to preserve foreign custody through announcements, collection, and committed replay.

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

The canonical report supplies a deterministic boundary reproduction, and current-main source still lacks foreign-custody checks; this read-only review did not execute tests or reproduce a production incident.

Is this the best way to solve the issue?

The patch fixes the owning invariant by connecting existing custody facts to orphan repair and provider conversion, preserves separate execution checks, and replaces committed replay’s separate lifecycle closure with the registered owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Accepted-input collection and committed consumption keeps the original intent (5f0aa4f: Retain acknowledged browser follow-ups across restarts and consume collected sources atomically with their combined transcript turn.)
  • Transcript reload inside orphan-repair admission keeps the original intent (6b3aa62: Keep native Talk consultations running when speech advances the transcript by refreshing and recomputing repair under the existing write admission.)
  • Persisted-current-turn hydration shortcut keeps the original intent (3eb77aa: Avoid unnecessary transcript hydration when the adopted current input already proves orphan repair unnecessary.)
  • Committed replay authority and lifecycle keeps the original intent (38d1253: Carry prepared sharing and custody facts through worker operations while retaining live caller validation before dispatch or commit.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +199, Tests +527, Docs +4. Total +730 across 18 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 7 278 79 +199
Tests 10 602 75 +527
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 884 154 +730

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +278/-79; tests and routing +602/-75 The production growth connects existing custody, promotion, replay, and attempt preparation; it introduces no persistent store or parallel custody registry.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #165500
Summary: This PR is the active repair for the canonical accepted-input announcement-isolation report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The demonstrated defect affects overlapping accepted input and announcements within one session; production incidence and an affected release range remain unestablished.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide Gateway runtime evidence exercising the revised custody and committed-replay implementation.

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 (24 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-09T03:42:00.616Z sha efb329bd56806611b7b5e3eec04df4b7aeaed458 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-10T02:26:14.294Z sha 1a6d9a3a868e3dc50f0998548e4d42fa6c0a97c9 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-12T02:31:41.941Z sha 6b8b6f1edf9201d55a5028d339728aa379ac2ddc :: needs maintainer review before merge. :: none
  • reviewed 2026-10-15T11:59:30.426Z sha 365d01a5b0d9b3873e06ad60afc0526350593e7b :: needs maintainer review before merge. :: none
  • reviewed 2026-10-18T03:51:27.030Z sha 3b2debc17541d85236cd2df4f36d917832af4538 :: needs changes before merge. :: none
  • reviewed 2026-10-18T09:45:21.424Z sha ef1fcc2e314c2d8974e6e5aa3e76c81de8d080a9 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-25T04:59:47.948Z sha 6857b02 :: needs real behavior proof before merge. :: [P2] Update replay rejection coverage for registered committed custody
  • reviewed 2026-10-25T05:16:01.189Z sha 7b71b75 :: needs real behavior proof before merge. :: [P2] Update replay rejection coverage for registered committed custody

Reviewed October 25, 2026, 1:38 AM ET / 05:38 UTC (Revision 25).

@chuanleiguo
chuanleiguo marked this pull request as ready for review October 2, 2026 17:12
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 2, 2026
@chuanleiguo

Copy link
Copy Markdown
Contributor Author

Real after-fix verification on 6494b6a53871a9984e20dfa523949a9032615dd4: a user-operated run recorded October 2 at 20:55 UTC used an isolated real Gateway/SQLite and official DeepSeek Responses (deepseek-flash). All four forwarded requests returned HTTP 200 and response.completed. Both consecutive same-session announcement requests contained zero copies of the protected accepted input; the original continuation contained one copy. Original dispatch and final reply occurred once, the canonical input remained once, and the final assistant stopped normally. Cleanup passed.

The fixture paused only inbound dispatch scheduling after the real chat.send ACK; custody, persistence and context filtering used the production paths. A bounded local relay forwarded real provider responses and preserved input/history. Announcements were direct agent RPCs carrying inter-session subagent_announce provenance. This does not cover actual child spawning/completion or multi-source aggregate live behavior. Cancellation released custody and produced no additional forwarded requests, but occurred after the forwarding allowance was exhausted, so it is not independent live cancellation proof.

Data compatibility: promotedOwner is a host-memory reference excluded from explicitly copied worker facts. No SQL, schema, serialized-message, configuration or migration contract changed. Legacy consumed-input identity, collected rewrite/restart and async custody coverage passed within the 57 selected committed regressions.

@chuanleiguo

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now includes the verified after-fix official DeepSeek Responses evidence for exact head 6494b6a53871a9984e20dfa523949a9032615dd4, the explicit live-proof limitations, current CI status and data-model compatibility evidence. Please reassess the remaining proof and compatibility asks.

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 2, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 4, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Oct 5, 2026
@chuanleiguo

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Copy link
Copy Markdown
Contributor Author

Hi @steipete, the conflicts are resolved and this PR remains a single commit. CI is green on head 3f8e17b6, and the description now records the updated validation.

Could you please review and consider merging when you have a chance? Thanks!

steipete and others added 2 commits October 24, 2026 21:43
Keep foreign accepted inputs out of announcement orphan repair and model
context by consulting the existing pending-input owner. Publish collect
promotion at commit and retain committed replay custody without changing
execution authority or persistent state.

Preserve the contributor's original work while integrating current main and
reducing the implementation to the custody-to-attempt boundary.

Co-authored-by: Chuanlei Guo <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL 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.

[Bug]: Same-session announcements can consume another active request's accepted chat input

2 participants