Skip to content

fix(sessions): carry question answer custody into async writes - #169306

Merged
steipete merged 2 commits into
mainfrom
codex/ask-user-worker-custody-20261011
Oct 11, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/ask-user-worker-custody-20261011

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The async transcript writer rejected an accepted ask_user answer as an unrelated new user turn. The waiting agent can now persist its tool result and continue after its answer enters history.

User Impact

Structured-question continuations work through the production worker-backed session manager. Unrelated user turns, changed transcript branches, cancellation, revoked authority and rewritten answer sources still prevent stale writes. No configuration or schema migration is required.

Why This Change Was Made

Question-answer custody was held in host AsyncLocalStorage, while worker turn validation could see only the original admission. Capture the existing owner's answer receipts once and carry those facts into the shared append kernel. The host's existing transaction/commit assertions revalidate live custody; the kernel checks current row identity. The old host-only per-row lookup is removed. Deslop retained the necessary explicit worker contract rather than adding a fallback or second authority owner.

Evidence

Converting the existing partial-then-complete regression to openAsync and appendMessageAsync failed before the repair with SqliteTranscriptMutationConflictError after the answer persisted. The same positive case passed after the repair. All eight question scenarios now exercise async writes, including foreign registration, unrelated user, retired authority, changed branch, rewritten source, missing generation and cancellation.

Question-answer, ancestry and ask-user rewrite-settlement proof: 28/28 pass across three files, 155.959 seconds wall time; question case bodies total 12.727 seconds. The original focused async regression took 113.410 seconds cold wall time, including 42.767 seconds preparing workers, and failed as expected. Fresh isolated Codex review through P2: scoped-clean. Production delta: +27 lines after removing superseded lookup logic. The original production head passed exact-head CI, including all source, type, lint, guard, documentation and boundary jobs. After those hosted jobs completed, the duplicate local changed-check run was interrupted with exit 130; its format, guards, core graph boundary, production types and first five test graphs had passed. This is reused hosted coverage, not a full local-check pass.

The followup strengthens the existing closed-authority case at the real worker's final commit admission. The revocation hook ran exactly once after receipt transfer, the append returned its authority conflict, persisted tool-result count was zero, and the provider did not resume. Allowed partial/final continuation, unrelated input, queued revocation and cancellation passed together: 4/4 selected cases, 28.636 seconds wall time; revoked-commit case 278 milliseconds. The owning agents-sessions test typegraph passed in 57.997 seconds, targeted type-aware lint in 65.914 seconds including artifact-lock wait, and formatting/diff checks passed. Fresh isolated final-diff review through P2 is scoped-clean (89.651 seconds). Production bytes are unchanged by this test-only followup. Final-head enforced CI passed on a3baf27; all 69 jobs completed successfully or were skipped. The final-head ClawSweeper review marked the owner-boundary proof sufficient and reported no findings.

This is production-owner transcript and authority proof: it exercises the shared async storage boundary and reads the committed transcript. The change does not alter any Telegram or other channel transport contract.

@clawsweeper

clawsweeper Bot commented Oct 11, 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 agents Agent runtime and tooling size: S labels Oct 11, 2026
@steipete
steipete marked this pull request as ready for review October 11, 2026 19:23
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR carries accepted question-answer receipts into async transcript writes while preserving live authority and transcript identity checks.

Example: A waiting ask_user turn receives destination Lisbon and budget 2000.

  • Before: The answer persists, but the worker rejects the waiting turn's tool-result append as an unrelated newer user turn.
  • After: The original turn stores its tool result and continues once, provided its authority and transcript branch remain current.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful repair with meaningful worker-boundary and revocation coverage; evidence is reported harness execution rather than a shipped-entry-point capture.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (none): The reported production-owner runs exercise openAsync and appendMessageAsync against real worker persistence: allowed answers produce one stored tool result and continuation, while revocation after receipt transfer at commit produces zero stored tool results and no continuation. The inspected probe delegates to the original admission owner. This satisfies the authority-specific harness allowance for this maintainer-authored PR; it establishes no live-channel or full-Gateway claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Answering a waiting agent's question can save the answer but prevent the original agent turn from continuing.
Reason: This restores the established question-continuation contract on the production async persistence path, with direction supplied by the maintainer-authored item and corroborated by prior area history.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current async question-continuation failure, and no actionable introduced defect was found. The follow-up addresses the earlier commit-time revocation concern; exact-head CI remains pending.

Priority: P1
Reviewed head: a3baf27d6de8fc2eaf9ec615d85d3651b69ab018

Before merge

None.

Findings

None.

Agent review details

How this fits together

The session persistence layer receives prepared agent messages and host-held answer receipts, validates them through the existing worker append owner, and publishes committed transcript results.

flowchart TD
  A[Accepted question answer] --> B[Host answer custody]
  B --> C[SessionManager persistence]
  C --> D[Worker append kernel]
  D --> E[SQLite transcript]
  C --> F[Live authority assertion]
  F --> D
  E --> G[Waiting agent continuation]
Loading

Technical review

Best possible solution:

Retain the explicit receipt transfer through the existing append owner and its live authority checks.

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

Current-main source shows the worker cannot access host-held answer custody, and the PR reports the converted async regression failing with SqliteTranscriptMutationConflictError before repair; this review ran no target code.

Is this the best way to solve the issue?

The patch repairs the host-to-worker boundary directly, updates both async adapters and synchronous validation, and removes the replaced lookup without creating a second authority owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Question-answer custody and stale-turn exemption keeps the original intent (813b505: Accept exact persisted answers held by the live question creator while rejecting unrelated input, stale authority, changed branches, and rewritten sources.)
  • Transcript store aliases keeps the original intent (32d4938: Recognize aliased paths as the same physical transcript store.)
  • Async actor append ownership keeps the original intent (5843d60: Route transcript appends through the session actor while preserving committed receipts, live authority, and accepted-write settlement.)
  • Synchronous prepared-append validation keeps the original intent (68be5fd: Validate bounded transcript ancestry and return an exact mutation fence for guarded operations.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 813b505 adds src/config/sessions/session-transcript-read-fence.ts:25 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 813b5052fb05; files: src/config/sessions/session-transcript-read-fence.ts)

PR surface

Source +27, Tests +16, Docs +5. Total +48 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 60 33 +27
Tests 1 19 3 +16
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 84 36 +48

Review metrics

Metric Value Why it matters
Production versus test LOC Production +60/-33; tests +19/-3 Production growth transfers worker facts and preserves live host checks while removing the old lookup; tests move existing scenarios to async persistence and strengthen commit-time revocation coverage.

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.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: An accepted question answer can leave the waiting agent unable to persist its tool result and continue.
  • 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.
  • 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-10-11T19:29:30.915Z sha 5ac7122 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-11T19:36:21.428Z sha 5ac7122 :: needs real behavior proof before merge. :: none

Reviewed October 11, 2026, 3:44 PM ET / 19:44 UTC (Revision 3).

@steipete steipete removed the proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. label Oct 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 11, 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: 🦐 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 11, 2026
@steipete
steipete merged commit e353566 into main Oct 11, 2026
145 of 149 checks passed
@steipete
steipete deleted the codex/ask-user-worker-custody-20261011 branch October 11, 2026 19:53
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…law#169306)

* fix(sessions): carry question answer custody into async writes

* test(sessions): fence question custody at worker commit
amittell added a commit to amittell/openclaw that referenced this pull request Oct 18, 2026
…ound append (openclaw#174994)

The settlement rebase already admits an intervening user turn when the
ingress claim carries it into the blocked run's questionAnswers custody
(openclaw#169306). Pin that production shape end to end: the settlement runs
inside withSessionTranscriptQuestionAnswers, the answer is a real
UserTurnTranscriptRecorder persisted by a claim that admits it after
persistApproved(), and the toolResult lands after the inbound answer
instead of dying with a rebase refusal.
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
First-parent upstream e63e209..0b0c2f2 (93 commits, including
openclaw#169144 subagent work across gateway restarts, openclaw#169251 worker write
transaction overhead, openclaw#169306 question-answer custody, openclaw#169305 fallback
ordering, openclaw#169339 owner-state rechecks, openclaw#169235/openclaw#168887 Solid UI ports).
Stops before openclaw#169315 (fp#248, agent schema), which is step 59 on its own.

Conflicts:
- embedded-agent-runner/run/payloads.ts: upstream gates the
  assistant-texts branch on !assistantForPayload (an empty canonical
  terminal stays authoritative); kept our per-hop raw-answer split for
  earlier continuation signals ahead of it.
- session-reset-cleanup.test.ts: upstream's retainEmbeddedSessionPromptState
  disposable; kept our async clearSessionResetRuntimeState call.
- plugin-sdk-surface-report.mts: upstream 3674/2135, ours +11/+4.
- config-baseline counts/sha256 and worker-access inventory regenerated
  on the merged tree (core +17 fork config entries, as before).

Auto-merged files that carry continuation overlay (19, incl.
attempt-execution, agent-runner-fallback-candidate, session.ts,
status-message, stream/update handlers) keep the overlay byte-for-byte.

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
amittell added a commit to amittell/openclaw that referenced this pull request Oct 28, 2026
…logging and tests: 41 conflict files

Resolved against base v2026.10.8; each import kept only where the merged file uses it.

Ported onto beta.4's reshaped code (the fork change kept, beta.4's mechanism taken):
- heartbeat awareness dedupe: beta.4 (openclaw#169622) dropped the pre-send lifecycle recheck
  (`latest`); the dedupe compares the prepare-time worker read, the post-send re-read is
  readSessionEntryReadOnlyInWorker with readConsistency "latest".
- prompt prelude: openclaw#166869's space-joiner ordering applies to `text`; the fork's
  version-3 Telegram carrier keeps the paragraph order (no joiner completes it).
- directive acks: beta.4 removed the thinking-remap ack; the fork's queue-ack helper stays.
- secret redaction: beta.4 (openclaw#169063) removed the registry snapshot scope; the fork's
  getLongestRegisteredSecretLength loses its scoped branch and its scoped test case.
- committed-turn entry read (pending inputs): beta.4 replaced PendingInputScope.incognito
  with session-actor storage; the read goes through readSessionEntryReadOnlyInWorker.
- persisted install records: beta.4 (openclaw#169714) made the reader async; install-persistence
  and the CLI test mocks use readPersistedInstalledPluginIndexInstallRecordsAsync.
- sessions.patch and cron validation mock modules (fork line-cap extractions) take
  beta.4's readAcpSessionMetaForEntryAsync, cron-session-reader and inference-binding mocks.
- test cases beta.4 removed as low-value (openclaw#172040) stay removed; the fork's own cases stay.

Native in beta.4, fork side dropped: question-answer custody in prepared-assistant
validation (openclaw#169306), the realtime-voice turn exception, the cron host test helper.
amittell added a commit to amittell/openclaw that referenced this pull request Oct 28, 2026
…tart-recovery conflicts

Takes beta.4 where it carries a fork change natively. Elsewhere it keeps the
fork's delta on top of beta.4's code.

- Native on beta.4, fork copies dropped:
  - openclaw#169306 (e353566): session-manager-persistence.ts and
    session-manager-metadata.worker.ts are byte-identical to beta.4. The
    fork's session-manager-append-custody.ts pull-forward is deleted; it has
    no importers left.
  - openclaw#158161 (177b090): classify.legacy-provider-predicates.test.ts is
    byte-identical to beta.4, whose corpus carries the same three TGI rows.
  - runtime-read.ts is beta.4's re-export. The fork's skipInheritance option
    moves to runtime-read.types.ts, where beta.4 now defines
    LoadAuthProfileStoreOptions (store.ts and models auth clean pass it).
- Fork deltas kept on beta.4's code:
  - auth-controller.ts: openclaw#93952's withAuthDeadline around beta.4's
    forceRefresh argument object; the cooldown-probe extraction and its
    re-export stay (it inlines beta.4's file-local resolveUnavailableAuthReason).
  - auth-controller.test-support.ts: beta.4's runtime-provider change, which
    its SIWC tests need, moves into the fork's split-out harness.
  - failover tests: beta.4's case moves, plus the fork's Anthropic long-context
    429 overflow test and its classified-reason 5xx copy test.
  - assistant-failure.ts: union of imports (recordModelFallbackStop and
    isPreDispatchToolCallRejectionMessage).
  - session-store.ts: the fork's per-attempt contextSnapshot ahead of beta.4's
    buildMainSessionRecoveryAfterAgentRunPatch, so recovery sees its totals.
  - session-manager-entries.ts: the fork's checkpoint-handle formatter with
    beta.4's createEntry timestamp.
  - restart recovery (dispatch, delivery, tests): beta.4's
    prepareRestartRecoveryDeliveryCurrent and isCurrent structure; the fork's
    restart-cause wording passes cause to announceRestartRecoveryResumption.
  - oauth-common-mocks.test-support.ts: beta.4's importOriginal spread, keeping
    the fork's syncEnvBackedTokenCredentials identity override.
  - docs/concepts/oauth.md: the fork's dead-grant paragraph in beta.4's wording.
- Tests that follow upstream's openclaw#170532 pruning: 3 of the 5 tests in the
  fork's transcript-file-state.compaction-checkpoint.test.ts are removed,
  because upstream deleted the same tests; the 2 that remain keep the
  checkpoint-handle pins.
- runtime-context-prompt.ts: the clean merge ran the fork's carrierText
  through openclaw#166869's joiner-aware append, which puts late context first for a
  space joiner. The carrier is rendered without a joiner (prompt-prelude.ts),
  so it gets its own paragraph-order append. The existing joiner test now
  pins carrierText for both joiners.

Not built here (no builds on this host); tsgo and tests run on the M4.
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 P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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