Skip to content

fix(sessions): accepted chat input fails when a same-session announcement runs first - #162473

Closed
chuanleiguo wants to merge 3 commits into
openclaw:mainfrom
chuanleiguo:fix/preserve-foreign-live-input
Closed

chuanleiguo wants to merge 3 commits into
openclaw:mainfrom
chuanleiguo:fix/preserve-foreign-live-input

Conversation

@chuanleiguo

@chuanleiguo chuanleiguo commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Supersedes #160962, narrowed to the core fix.

What Problem This Solves

Fixes: an accepted chat turn fails with Pending input is no longer active in its admitted transcript when a same-session announcement (for example a subagent completion) runs while that turn's input is promoted but not yet finished.

User Impact

Announcements no longer treat another live turn's accepted input as an orphan. They leave it in the transcript, keep it out of the announcement's model context, and the original turn then runs exactly once. Cancelled or revoked input is still never executed. No config, schema, stored-format or migration change.

Why This Change Was Made

Promotion consumes the pending-input row before its owning turn finishes, so orphan repair could not see that the input still had a live owner. Consumed source owners now keep a reference to the aggregate that promoted them, and the attempt boundary checks in-memory live custody (same database, session and transcript entry, owner still current) before it repairs or replays an orphan. When another turn owns the input, the boundary skips repair and filters that input out of agent state and every convertToLlm rebuild for this attempt.

The pre-adoption lifecycle reservation and the Bedrock distinct-user-turn replay from #160962 are separate concerns and are left for follow-up PRs.

Evidence

Base: origin/main 558d38a3db5.

  • Red on main: the new attempt-session-boundary.live-input.test.ts fails 2/3 cases on unpatched main (live collected input, revoked input). In both, the announcement's provider request contains the other turn's queued user request. The excludeFromContext case passes on both, as the control.
  • Green with fix: attempt-session-boundary.live-input.test.ts, session-accessor.pending-inputs-consumed.test.ts, and the existing attempt-session-boundary.test.ts pass 89/89.
  • Test cost: pnpm test src/agents/embedded-agent-runner/run/attempt-session-boundary.live-input.test.ts --maxWorkers=1 takes 24.9 s wall and 8.1 s Vitest duration (3 cases at ~1 s each, real SQLite plus the real attempt boundary and convertToLlm). The new accessor cases in pending-inputs-consumed.test.ts are in-memory and cheap.
  • node scripts/check-changed.mjs --staged: these pass: format, conflict markers, line-cap, max-lines, assertion SAFETY, SQLite worker, timeout-race ratchets, plugin boundaries, typecheck core, and the agents-root, agents-other, agents-tools and agents-sessions test-type graphs.
  • CI cost (run 36824502245): the live-input file took 11.9 s across its 3 cases (5.3 s, 3.3 s, 3.3 s) in checks-node-changed-compact-large-39. The three new pending-inputs-consumed cases took 0.53 s in checks-node-changed-compact-large-31.
  • Inherited CI failures: none of the 13 failed jobs are caused by this PR. The per-job triage is in the PR comments.
  • No stored-data change: promotedOwner is a process-local field on the in-memory owner. Transcript, session_pending_inputs and session rows are unchanged, so update and migration behavior is unaffected.
  • Real Gateway proof from fix(sessions): preserve accepted input during announcements #160962 (same production logic): an isolated Gateway and SQLite, driven through browser chat.send, sessions_spawn, child completion and announcement. The announcement request contained zero copies of the queued input. The original turn then ran once with one copy. A chat.abort-cancelled input produced no provider request.

Known limits (unchanged from #160962, not addressed here)

  • The check that excludes the attempt's own owner uses ambient AsyncLocalStorage. An announcement that inherits a live parent's owner context would treat that parent's input as its own. This is unlikely because a spawning turn already has an assistant entry after its input. Passing the attempt's owner explicitly would remove the dependency.
  • Only the foreign user message is hidden. Assistant or tool entries that the foreign turn appends during the announcement's tool loop are not filtered.

…ted input

Promotion consumes the pending-input row before its owning turn finishes,
so a same-session announcement saw that input as an orphan leaf and either
repaired it away or replayed it into its own model context. The original
turn then failed with "Pending input is no longer active in its admitted
transcript".

Consumed source owners now keep the aggregate that promoted them, and the
attempt boundary checks live in-memory custody before orphan repair. When
another live turn owns the input, the boundary skips repair and filters it
out of the announcement's agent state and convertToLlm rebuilds.
@clawsweeper

clawsweeper Bot commented Oct 1, 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: M labels Oct 1, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 12:10 PM ET / 16:10 UTC (Revision 5).

ClawSweeper review

What this changes

The PR preserves another live turn’s accepted input during same-session announcements and excludes that input from the announcement’s model context.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main. No introduced blocking defect was found, and the previous migration-proof blocker is cleared because the added ownership reference is process-local.

Priority: P1
Reviewed head: fe9e2350536db99e5a74f2527704063c6280e9ed

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant retained runtime proof, meaningful boundary regressions, and no supported blocking finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Retained real Gateway/provider output exercises chat.send, child completion, announcement exclusion, original-turn execution once, and chat.abort rejection for the changed custody/filter behavior. Current-head real writer-worker regression coverage supplements the async publication adaptation. The ownership reference is neither serialized nor persisted, so the previous migration-proof requirement is cleared.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Retained real Gateway/provider output exercises chat.send, child completion, announcement exclusion, original-turn execution once, and chat.abort rejection for the changed custody/filter behavior. Current-head real writer-worker regression coverage supplements the async publication adaptation. The ownership reference is neither serialized nor persisted, so the previous migration-proof requirement is cleared.
Evidence reviewed 8 items Introduced changes and current-main necessity: The pinned introduced delta adds foreign-owner reconciliation and filtering. Comparing fetched main with the exact head shows that main still lacks these protections; the merged pending-history refactor addresses a different operation.
Previous compatibility blocker resolved: promotedOwner is an in-memory object reference. The explicit worker-facts type and copy operation exclude it, and the introduced changes do not alter SQL, schemas, serialized messages, configuration, or migration contracts. The earlier request for migration proof therefore does not apply.
Scoped live-owner checks: Foreign protection matches database path, session ID, session key, and transcript entry, excludes the current owner, and invokes the existing live-authority assertion. Finished, revoked, or lifecycle-retired owners do not qualify; the new reference grants no execution authority.
Findings None None.
Security None None.

How this fits together

OpenClaw’s session runtime promotes accepted chat input into a durable transcript before its turn finishes. Announcement preparation reads that transcript and builds the next provider request.

flowchart TD
  A[Accepted chat input] --> B[Transcript promotion]
  B --> C[Live input ownership]
  D[Same-session announcement] --> E[Attempt preparation]
  C --> E
  E --> F[Announcement provider context]
  C --> G[Original turn continues]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +102, Tests +321. Total +423 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 6 105 3 +102
Tests 4 321 0 +321
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 426 3 +423

Review metrics

Metric Value Why it matters
Production versus regression growth production net +102 LOC; tests +320 LOC Production growth implements committed custody publication and repeated context filtering; regression growth covers the attempt and writer-worker boundaries.

Root-cause cluster

Relationship: canonical
Canonical: #162473
Summary: This is the narrowed landing candidate for foreign live-input protection; the merged history-reader refactor does not replace it.

Members:

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

Technical review

Best possible solution:

Keep the existing custody owner authoritative through promotion and exclude foreign accepted input throughout announcement context rebuilds.

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

Yes: source establishes promotion followed by announcement orphan repair as the failure path, and the contributor reports failing pre-fix boundary cases. This read-only review did not execute a reproduction.

Is this the best way to solve the issue?

Yes: retaining live custody through the existing owner and filtering at the provider-context boundary is a focused repair without a competing queue or stored-format change.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: A same-session announcement can invalidate an already accepted chat turn and prevent its normal execution.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Retained real Gateway/provider output exercises chat.send, child completion, announcement exclusion, original-turn execution once, and chat.abort rejection for the changed custody/filter behavior. Current-head real writer-worker regression coverage supplements the async publication adaptation. The ownership reference is neither serialized nor persisted, so the previous migration-proof requirement is cleared.
  • proof: sufficient: Contributor real behavior proof is sufficient. Retained real Gateway/provider output exercises chat.send, child completion, announcement exclusion, original-turn execution once, and chat.abort rejection for the changed custody/filter behavior. Current-head real writer-worker regression coverage supplements the async publication adaptation. The ownership reference is neither serialized nor persisted, so the previous migration-proof requirement is cleared.

Evidence

What I checked:

  • Introduced changes and current-main necessity: The pinned introduced delta adds foreign-owner reconciliation and filtering. Comparing fetched main with the exact head shows that main still lacks these protections; the merged pending-history refactor addresses a different operation. (src/agents/embedded-agent-runner/run/attempt-session-prepare.ts:352, fe9e2350536d)
  • Previous compatibility blocker resolved: promotedOwner is an in-memory object reference. The explicit worker-facts type and copy operation exclude it, and the introduced changes do not alter SQL, schemas, serialized messages, configuration, or migration contracts. The earlier request for migration proof therefore does not apply. (src/config/sessions/session-accessor.sqlite-pending-inputs.ts:63, fe9e2350536d)
  • Scoped live-owner checks: Foreign protection matches database path, session ID, session key, and transcript entry, excludes the current owner, and invokes the existing live-authority assertion. Finished, revoked, or lifecycle-retired owners do not qualify; the new reference grants no execution authority. (src/config/sessions/session-pending-input-live-owner.ts:18, fe9e2350536d)
  • Writer-worker publication coverage: The existing real SQLite writer-worker regression now checks foreign protection after committed promotion, access from the owning context, and release after cancellation for ordinary and collected input. The host publishes the aggregate reference through its existing acknowledged worker receipt. (src/agents/sessions/session-manager-async-message.test.ts:308, fe9e2350536d)
  • Retained real Gateway/provider proof: The captured body of fix(sessions): preserve accepted input during announcements #160962 records an isolated real Gateway, SQLite, authenticated browser RPCs, native runtime, and real Responses service at d75cd3e. The announcement request contained zero copies of the accepted input, its original continuation contained one copy and produced one final reply, and chat.abort prevented any subsequent provider request. This PR explicitly retains that proof for the narrowed custody/filter behavior; current-head worker coverage supplements it. (d75cd3e3cd7c)
  • Regression quality and reported validation: The new boundary cases exercise actual transcript promotion, attempt preparation, provider-context conversion, context rebuilds, and original-turn continuation with a mocked provider. The body reports two failures on unpatched main and 89 focused passes; the latest commit records 143 focused passes after async integration. These are contributor-reported results, not tests executed during this review. (src/agents/embedded-agent-runner/run/attempt-session-boundary.live-input.test.ts:27, fe9e2350536d)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • 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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-01T06:28:30.627Z sha 2be5bcb :: blocked before merge. :: none
  • reviewed 2026-10-01T07:39:21.243Z sha 2be5bcb :: blocked before merge. :: none
  • reviewed 2026-10-01T08:12:18.763Z sha 2be5bcb :: blocked before merge. :: none
  • reviewed 2026-10-02T08:31:57.720Z sha 36468d3 :: blocked before merge. :: none

@chuanleiguo

Copy link
Copy Markdown
Contributor Author

CI triage for run 36824502245 (head 2be5bcb72ff, base 558d38a3db5). None of the 13 failed jobs are caused by this PR.

Failed jobs Cause Evidence
check-prod-types, check-test-types-core-1…5, checks-ui-e2e (4/9) Base 558d38a3db5 was missing the readMissingScopeError import in ui/src/components/session-group-defaults-dialog.ts, introduced by #139024. The e2e failure is the same feature (shows the admin requirement…, stuck at checking). Already fixed on main by 03137c1d729.
checks-fast-baseline-ratchets check-database-worker-ratchet crashes with spawnSync rg ENOENT: scripts/database-worker-inventory.mjs spawns rg, and that job has no ripgrep. Not changed by this PR. Still present on current main.
checks-node-changed-compact-large-33 / -7 update-cli.admission-ledger (Phase: verifying) and update-cli.windows-lifecycle (ENOENT dist/index.js). Both fail locally on base 558d38a3db5 without this PR. The same failures appear on other PRs: runs 36827431913, 36826612408, 36826288587.
checks-node-changed-compact-large-8 swarm-tools.integration drain order: the third collector was missing after a real timeoutSeconds: 1 wait on a loaded runner. The test drives children through mocked callGateway and never reaches the attempt boundary changed here. It passed 8/8 locally on this head.
checks-node-changed-compact-large-19, checks-windows-node-test-4 session-files.windows-ownership (ENOENT on a simulated Windows temp path) and Windows sqlite-creation-worker (Session creation publication owner is no longer current, after a 30 s no-output stall). Neither test nor the creation-publication owner references pending-input custody. Both passed 3/3 locally on this head. I could not run them on Windows.

On the ClawSweeper "persistent data-model change" flag: there is no stored-format change. promotedOwner is a process-local field on the in-memory pending-input owner. Transcript entries, the session_pending_inputs schema and session rows are written exactly as before, so no migration or update step is involved.

I will push once, without rebasing for anything else, after the rg provisioning fix lands, so CI can pick up both upstream fixes.

@chuanleiguo

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Copy link
Copy Markdown
Contributor Author

CI update after the upstream fixes landed: pushed one empty commit, 36468d3, with no patch changes or rebase.

Fresh CI run 36983749308 tested merge 2bdec7115367 against base e6b3a11, which includes both the ripgrep provisioning and readMissingScopeError import fixes. It finished with 92 jobs passing, 23 skipped, and one failing test job plus the aggregate CI gate. All 14 companion workflows passed.

The remaining failure is test/scripts/write-unified-entry-dts.test.ts:241, “reuses unaffected canonical groups while rebuilding runtime after input edits”. Its temporary package fixture exports only ./error-coercion, while src/process/exec-result.ts imports @openclaw/normalization-core/record-coerce, producing ERR_PACKAGE_PATH_NOT_EXPORTED.

Source inspection points to an existing base fixture mismatch; both files are outside this PR’s diff. I have not independently reproduced it locally.

Merge upstream/main at 0845ecd into fix/preserve-foreign-live-input,
retaining both histories and upstream runtime-context projection tracking.
Await the updated history APIs in the live-input regression fixtures.

Publish aggregate custody back to the host after the metadata writer
commits, so an announcement cannot repair or consume another live turn.
Keep the live-owner lookup in its own module within the line budget.
Extend the real writer-worker regression to verify foreign protection,
own-context access, and release after cancellation.

Validation: 143 focused tests passed; the 59 affected regressions also
passed after extraction. Independent autoreview returned scoped-clean
with no actionable P0-P2 findings. Core production types and selected
architecture checks passed; remaining validation is recorded separately.
@chuanleiguo

Copy link
Copy Markdown
Contributor Author

Superseded by #163655, rebuilt as one focused commit on fresh upstream main.

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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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