Skip to content

fix(sessions): avoid pauses decoding unrelated prompts during creation - #139529

Merged
steipete merged 2 commits into
mainfrom
codex/session-create-preparation-20260905
Sep 6, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/session-create-preparation-20260905

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #139526

What Problem This Solves

Fixes pauses when creating or adopting sessions in agent stores containing large saved prompts. Creation previously decoded every saved prompt in the store before invoking its preparation callback, including when that callback ignored the store.

Why This Change Was Made

The existing snapshot owner now supports an uncached selective-full read: requested/canonical/folded target candidates retain their complete payloads while sibling rows use the established metadata projection. The same SQL row snapshot supplies target and label facts. Existing participant hydration remains its separate query; no transaction or broader consistency guarantee is introduced.

The internal callback receives its resolved existing entry, distinct exact target entry, and detached label predicate. Gateway adoption keeps its full original payload. Existing canonical-key, malformed-row, owner, participant, transcript/lifecycle and commit-guard behavior remain in place. The default SDK callback continues using the same creator without consuming snapshot context.

User Impact

Creating a session avoids allocating unrelated saved prompt payloads. Adoption preserves saved skill snapshots and system-prompt reports; existing label rejection, incognito scope and guarded initialization behavior remain unchanged.

Evidence

  • The final regression failed with the original creator: three unrelated prompt JSON decodes instead of zero. The candidate passes and retains the full adopted target.
  • Owner and Gateway tests cover cold/opaque keys, warm malformed/NUL/identity/time mismatches, cold validation rejection, owner/participant fields, an external SQLite commit during row iteration, post-await snapshot stability, cache isolation, and saved-payload retention through real Gateway creation/adoption.
  • No schema, index, persisted projection, new cache, locking, transaction-boundary, public SDK or operator configuration change. Ordinary cached reads remain unchanged; selective creation snapshots are uncached.
  • Existing readers offer uniform full or metadata projections; they cannot preserve selected complete targets and sibling metadata in one row snapshot. Additional production code implements selective complete-target snapshots and detached callback facts in the existing materialization owner. It replaces the full-store callback and removes unnecessary Gateway record assignments; no parallel parser or fallback reader is retained.

Compiled Gateway proof on source 36beea075b748e33da163d2173f7f760d180b06f completed four token-authenticated sessions.create scenarios: new creation, full-target adoption, duplicate-label rejection, and structural-key normalization. A separate process verified saved target prompt/report hashes, the new session, absence of the rejected row, and all 100 unchanged siblings. Source/build/harness seals remained stable and the Gateway shut down cleanly. The isolated proof environment has been stopped.

The combined proof command exited 1 because an additional default-manager SDK probe attempted an internal module path absent from the compiled artifact. That constructor is not exported by the supported compiled SDK barrel; no SDK construction or provider turn ran. The completed Gateway phases are qualified separately, and source-level ignored-context preparation coverage remains separate evidence.

Initial CI found three missing brace pairs in the new tests. Commit 685ae5004823446963b1bc99152d5174da7c2063 fixes only those test blocks; targeted lint and independent review passed. All production files remain identical to the compiled proof. Exact-head CI passed; native preparation verified its hosted gates on 685ae5004823446963b1bc99152d5174da7c2063. Synthetic accessor/preparation measurements do not establish production end-to-end latency.

@clawsweeper

clawsweeper Bot commented Sep 5, 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 gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Sep 5, 2026
@steipete
steipete marked this pull request as ready for review September 5, 2026 23:55
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 8:19 PM ET / September 6, 2026, 00:19 UTC.

ClawSweeper review

What this changes

Session creation reads complete saved state for target sessions while using lightweight sibling metadata for label checks.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main and v2026.9.2 still prepare creation callbacks by loading unrelated saved prompts. No actionable introduced defect was found.

Priority: P2
Reviewed head: 685ae5004823446963b1bc99152d5174da7c2063

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no identified correctness blocker.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary contributor proof gate does not apply to this maintainer-authored PR. Its body separately reports compiled Gateway creation, adoption, label rejection, and normalization with persisted-state verification; production blobs still match that revision. The failed SDK probe and unmeasured end-to-end latency are explicitly excluded.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary contributor proof gate does not apply to this maintainer-authored PR. Its body separately reports compiled Gateway creation, adoption, label rejection, and normalization with persisted-state verification; production blobs still match that revision. The failed SDK probe and unmeasured end-to-end latency are explicitly excluded.
Evidence reviewed 10 items Current main still contains the reported preparation cost: The fetched main revision calls listSessionEntriesCore without a metadata projection, constructs the full store, and clones it into the creation callback.
Latest release retains full-store preparation: Inspected the same creation helper at the supplied v2026.9.2 release commit; it also materializes the full session store before invoking preparation.
Selective snapshot preserves the required facts: The new reader requests complete canonical/requested/folded candidates, applies existing listing visibility and key validation, and captures sibling labels excluding only the exact target. Mixed snapshots bypass the shared metadata cache.
Findings None None.
Security None None.

How this fits together

Gateway and internal SDK session creation share a SQLite-backed preparation helper. Its snapshot feeds session adoption, label validation, and guarded transcript and session writes.

flowchart TD
  A[Gateway or SDK creation request] --> B[Resolve session store and target]
  B --> C[Read target payload and sibling metadata]
  C --> D[Prepare entry and validate label]
  D --> E{Preparation accepted}
  E -->|Yes| F[Guarded transcript and session writes]
  E -->|No| G[Return creation error]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +81, Tests +304. Total +385 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 8 114 33 +81
Tests 4 319 15 +304
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 433 48 +385

Review metrics

Metric Value Why it matters
Production versus regression coverage Net production +81 lines; tests +304 lines Production growth implements selective reads in the existing owner; most growth protects payload preservation, snapshot consistency, and corruption behavior.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #139526
Summary: This PR is the explicitly linked implementation candidate for the reported full-store preparation cost.

Members:

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

Technical review

Best possible solution:

Keep creation preparation in the existing snapshot owner, preserving complete adoption state while avoiding unrelated prompt allocation.

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

Yes, source establishes the path: creating a session loads every full entry before even an ignored-context callback runs. The linked report supplies a quantified reproduction; this review did not execute it.

Is this the best way to solve the issue?

Yes. Extending the existing reader preserves target payloads and label semantics without adding a competing parser, cache, or persisted representation.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This addresses bounded session-creation pauses in stores containing large saved prompts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The ordinary contributor proof gate does not apply to this maintainer-authored PR. Its body separately reports compiled Gateway creation, adoption, label rejection, and normalization with persisted-state verification; production blobs still match that revision. The failed SDK probe and unmeasured end-to-end latency are explicitly excluded.

Evidence

What I checked:

  • Current main still contains the reported preparation cost: The fetched main revision calls listSessionEntriesCore without a metadata projection, constructs the full store, and clones it into the creation callback. (src/config/sessions/session-accessor.entry-mutation.ts:74, 89940df0a1a4)
  • Latest release retains full-store preparation: Inspected the same creation helper at the supplied v2026.9.2 release commit; it also materializes the full session store before invoking preparation. (src/config/sessions/session-accessor.entry-mutation.ts:74, 3928bad9badf)
  • Selective snapshot preserves the required facts: The new reader requests complete canonical/requested/folded candidates, applies existing listing visibility and key validation, and captures sibling labels excluding only the exact target. Mixed snapshots bypass the shared metadata cache. (src/config/sessions/session-accessor.sqlite-creation-read.ts:25, 685ae5004823)
  • Existing boundaries remain intact: Gateway adoption consumes the complete target; the internal SDK creator ignores callback context. The callback type is not exported through the public plugin SDK. Existing transcript and lifecycle commit guards remain unchanged, and the bound SQLite set helper avoids interpolating session keys into SQL. (src/gateway/session-create-service.ts:1150, 685ae5004823)
  • Regression coverage protects behavior: Read the added tests covering unrelated prompt decoding, full-target adoption, cold and opaque identities, malformed rows, external commits during iteration, post-await label stability, and cache isolation. Existing incognito and revoked-commit coverage remains. Tests were inspected, not executed. (src/config/sessions/session-accessor.creation-snapshot.test.ts:29, 685ae5004823)
  • Proof and re-review continuity: The captured PR body reports four compiled, token-authenticated Gateway scenarios on 36beea0, with separate-process verification of adopted payload hashes and 100 unchanged siblings. It explicitly excludes a failed internal SDK probe and any end-to-end latency claim. Raw tree comparison confirms only two test files changed afterward; all production blobs match the reported proof revision. The previous completed review retained no findings or published rank-up moves. (685ae5004823)

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 (1 earlier review cycle)
  • reviewed 2026-09-06T00:01:31.214Z sha 36beea0 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit f75c1f5 into main Sep 6, 2026
186 checks passed
@steipete
steipete deleted the codex/session-create-preparation-20260905 branch September 6, 2026 00:29
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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.

Session creation decodes saved prompts from unrelated sessions

1 participant