Repository navigation
feat: prepare async session SDK and incognito history reads - #167952
Conversation
Keep production incognito acquisition host-owned. Add complete public async entry and by-ID reads, latest-assistant history, and Memory/Active Memory consumer cutover. Preserve the released synchronous getter and the native paths reserved for activation. Initial isolated P2 review is clean; focused validation follow-ups are pending.
Capture explicit actor paths before ambient environment normalization. Use canonical reconciliation in the history fixture and migrate the required async runtime mock and ClickClack reader. Isolated P2 review is clean; remaining SDK fixture routing proof follows.
Revalidate the producer audience and abort state immediately before model invocation. The regression fails without this final check and passes with it. Share SDK entry getters through their existing internal projection owner to avoid twenty eager modules without changing public signatures. Repair host-worker fixture routing and literal types. Third isolated P2 review is clean.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThe plugin SDK, OpenClaw’s interface for plugins, adds asynchronous session reads, prepares private history access, keeps private recall transcripts from being exported, and reduces repeated database validation. Example: Use Active Memory in an incognito conversation with persistTranscripts enabled.
Review scores
ProductKind: Feature · Worth it: Yes Merge readiness✅ Ready for maintainer review This maintainer-directed prerequisite remains useful and is not superseded by current main. Earlier findings remain repaired, and this review found no new actionable code defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherPlugins and Active Memory read session metadata and conversation history through shared storage interfaces. Those interfaces select a durable database worker or an explicitly bound private session owner and return metadata or transcript content. flowchart TD
A[Plugin or Active Memory] --> B[Asynchronous session reader]
B --> C{Selected storage owner}
C --> D[Durable database worker]
C --> E[Bound private session actor]
D --> F[Source and lifetime checks]
E --> F
F --> G[Session metadata or history]
Technical reviewBest possible solution: Retain the existing storage owners and synchronous compatibility window through the later atomic incognito cutover. Do we have a high-confidence way to reproduce the issue? Not applicable as a single bug report: this PR adds an owner-directed SDK capability. The supplied correction evidence reports failing negative controls for the earlier compatibility and session-selection defects. Is this the best way to solve the issue? Yes: the patch extends existing worker and actor owners, preserves released-host capability selection, and separates descriptive metadata from live authority. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e39552c18106. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +594, Tests +918, Docs +58, Other +3. Total +1573 across 65 files. Added test files: 2. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 9, 2026, 8:23 PM ET / October 10, 2026, 00:23 UTC (Revision 5). |
Keep async entry reads and typed incognito errors on the existing session-store-runtime subpath. Apply the approved exact export budgets and document removal of synchronous getters at the next SDK major.
Prepare one request-owned parent entry for eligibility, fast mode, and channel context. Preserve final audience authority and current status cleanup reads. The regression fails the previous repeated-read path across a controlled metadata change.
Keep connection-local TEMP table creation and explicit cleanup from revoking shared MAIN schema receipts. Expire local facts and native mutation witnesses while preserving same-frame data versions and existing transaction, rollback, and main-schema invalidation.
Retain ClickClack support for released hosts, preserve Active Memory newest-session ID selection through the read owner, restore cold history before channel preparation, and exercise MAIN revocation with durable DDL. Released synchronous SDK signatures remain unchanged.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…#167952) * feat: prepare async session SDK and incognito history adapters Keep production incognito acquisition host-owned. Add complete public async entry and by-ID reads, latest-assistant history, and Memory/Active Memory consumer cutover. Preserve the released synchronous getter and the native paths reserved for activation. Initial isolated P2 review is clean; focused validation follow-ups are pending. * fix: retain physical session owners across async read preparation Capture explicit actor paths before ambient environment normalization. Use canonical reconciliation in the history fixture and migrate the required async runtime mock and ClickClack reader. Isolated P2 review is clean; remaining SDK fixture routing proof follows. * fix: fence recall after asynchronous metadata preparation Revalidate the producer audience and abort state immediately before model invocation. The regression fails without this final check and passes with it. Share SDK entry getters through their existing internal projection owner to avoid twenty eager modules without changing public signatures. Repair host-worker fixture routing and literal types. Third isolated P2 review is clean. * style: align async session fixtures with lint rules * feat(sdk): deprecate synchronous session entry reads Keep async entry reads and typed incognito errors on the existing session-store-runtime subpath. Apply the approved exact export budgets and document removal of synchronous getters at the next SDK major. * perf(active-memory): reuse parent metadata during recall Prepare one request-owned parent entry for eligibility, fast mode, and channel context. Preserve final audience authority and current status cleanup reads. The regression fails the previous repeated-read path across a controlled metadata change. * fix(sqlite): preserve main admission across temp scratch tables Keep connection-local TEMP table creation and explicit cleanup from revoking shared MAIN schema receipts. Expire local facts and native mutation witnesses while preserving same-frame data versions and existing transaction, rollback, and main-schema invalidation. * fix(sessions): preserve async adapter compatibility and history Retain ClickClack support for released hosts, preserve Active Memory newest-session ID selection through the read owner, restore cold history before channel preparation, and exercise MAIN revocation with durable DDL. Released synchronous SDK signatures remain unchanged.
Conflict in src/config/sessions/transcript.ts with main's openclaw#167952 (320d57b). Main moved readRecentUserAssistantTextForSession off synchronous main-thread reads: the session entry is now read in a worker (withSessionEntryReadOnlyInWorker), the store path can be an incognito actor's, every page comes from readSessionTranscriptBoundedMessageTailPageAsync, and readRestoredSessionTranscript takes the owner's assertCurrent. This branch had replaced the same read with a synchronous one-snapshot selection (readSessionTranscriptConversationSnapshot) followed by async grounding. Resolution: main's entry read, scope and assertCurrent stay as they are. The selection keeps this branch's contract (newest entries first, each assistant entry with the media from its own turn's earlier tool results, at most 1,000 rows of turn and 64 references) but now runs in selectRecentConversationRows on main's async tail-page reader, so it works off the Gateway thread and for incognito sessions. Offsets count from the end, so a write between pages would shift the next page onto rows already read and could lend a later tool result to an earlier reply; each page's projection snapshot (generation, indexed seq, boundary) must match the first, and a mismatch restarts the read. The third read that sees a change keeps paging, as replay did before, and returns every row with no references, so replay redacts their managed media rather than shortening the window. Grounding still runs after the cold-storage retry. The synchronous readSessionTranscriptConversationSnapshot, its type, its session-accessor re-export and its accessor test are removed; those three accessor files are main's again. Two new regressions land rows between pages: one write, where a reply's later tool result must not become its provenance, and a write in each of three reads, where the last read re-reads that tool result into the reply's turn and must still drop it and still reach the oldest row.
What Problem This Solves
Session plugins need asynchronous full-entry reads, and the incognito actor arm needs complete history and Memory adapters before its production cutover.
User Impact
Plugins gain
getSessionEntryAsyncandgetSessionEntryByIdAsyncon the existingopenclaw/plugin-sdk/session-store-runtimesubpath and runtime session object. Both return the complete public projection. Active Memory uses one request-owned parent snapshot for eligibility, fast mode, and channel context; private recall helpers stay private and never export debugging transcripts.The synchronous SDK/runtime
getSessionEntrygetters retain their synchronous behavior but are now deprecated in favor ofgetSessionEntryAsync, with removal at the next Plugin SDK major. Custom runtime implementations must implement the two required async methods. The approved SDK budget increase is exactly three exports/callables (3,641 → 3,644 exports; 2,111 → 2,114 callables); the deprecation budget increases by exactly one (147 → 148). The third export is the canonicalrethrowIncognitoSessionErrorhelper, keeping typed-error policy shared without pulling in the broader ACP runtime. No new subpath, root barrel, object, or per-entrypoint budget is added.Incognito activation remains inactive. Unbound incognito calls retain the native host owner and allocate no actor. No schema, stored-data, retention, permission, content-cap, or update migration is introduced, and no incognito T1 retirement is claimed. The published-driver × candidate update cell passed on landing head
74a74b76aedc; details below.Why This Change Was Made
The existing entry/history owners supply the asynchronous SDK, managed-runtime and Memory reads. Raw delta, latest assistant, exact visible-message delta and display delta retain their distinct contracts. Reads capture their physical source before awaiting; managed reads recheck plugin lifetime, and Active Memory checks current audience authority immediately before effects. Cleanup composes the existing lifecycle owner and preserves durable siblings.
Ordinary uncached Active Memory recall previously prepared the same parent metadata three times, or four when resolving by ID. It now retains one descriptive snapshot for the request. A controlled-await regression proves that channel and fast-mode metadata remain consistent during the request and refresh on the next invocation. This is not a persistent entry cache; status cleanup still reads current state and final authority guards remain live.
SQL attribution exposed a separate inherited producer defect: Memory's
DROP TABLE temp.memory_publication_inputrevoked the durable MAIN schema receipt. Every one of 25 repeated writer admissions in the causal diagnostic followed that TEMP cleanup and correctly responded to the falsely invalid receipt by repeating schema inspection. Those requests executed 988 statements, including 708 in warmed turns. The new SDK/by-ID/recent/latest facades executed zero times in that ordinary workload.The correction uses the existing schema-facts owner and the same TEMP/MAIN distinction as the sibling
noprobeimplementation. Proven TEMP-only table creation/cleanup expires connection-local facts and advances the existing local mutation witness without revoking MAIN admission. Mixed batches, unqualified drops, MAIN DDL/version changes, rollback and reentrant MAIN writes retain their guards. A regression also proves that TEMP handling adds no nested foreigndata_versionprobe.Evidence
Integrated
origin/mainonce ate69931d6e6a21b0067a9f474db50a86e9563f61e; the only textual conflict was resolved by retaining both independent registry lifetime test groups. Measured source:fe4190d230188a04f721ac4aadb008ab231cda5e.Measured diff against that base: 41 production files, +880/−325 (1,205 changed); 16 test/support files, +854/−23; four docs, +58/−2; two tooling files, +7/−3. Total: 63 files, +1799/−353. Test helpers are counted with tests. No changelog, dependency, line-cap, or timeout-race baseline changes.
Final SQL proof: five alternating main/candidate pairs on the same Node 26.10.0 host, pinned to
e69931d6e6a2→fe4190d23018. All ten workloads completed successfully; no attempts were excluded. The final source-map builds passed (main 89.53s; candidate 363.06s). The canonical UI build regenerated the same Workboard asset references in both checkouts; no diagnostic source changes were present. The harness disabled only automatic archive creation; workload, observer and analyzers were unchanged.First-turn samples: main
[2877, 2699, 1999, 1830, 2678]; candidate[2450, 2445, 2494, 2233, 2652]. Warmed per-turn samples: main[1107.6, 1130.6, 1129.7, 1133.7, 1093.9]; candidate[1120.0, 1136.1, 1092.4, 1117.2, 1068.4]. Both strict turn medians decrease without using the noise-floor exception. Every phase duration ratio is valid (maximum 1.192). Whole-workload median: 23,961 → 23,590 (−371 statements).The statement gate passes: strict first/warmed medians decrease; boot is within the non-turn 2% tolerance; shutdown is within the ten-statement tolerance. Compaction is assessed with the permitted adjacent Memory indexing/settlement window from second-session work through shutdown. The narrower compaction and compaction+shutdown increases remain visible above.
busy_timeout/ locking mode / transaction / version write, index revision and metadata readsFor the runs defining the compaction medians (main pair 2 and candidate pair 1), generic sync starts occur twice in main's second-session phase versus once in the candidate; compaction has zero versus one. Each has two generic starts across the full tail and one explicit post-compaction sync. Every one of the 24 positive compaction SQL/stack groups occurs in baseline traces; their combined count across the tail decreases 102 → 95. This locates existing generation work across phases rather than treating compaction's increase as a new SDK request.
Tail sums, in alternating-pair order: main
[6831, 7269, 6659, 6123, 6288]; candidate[6280, 6227, 6089, 6479, 6183]; median 6659 → 6227, duration ratio 0.782. The campaign rule compares medians, so pair 4's individual increase remains recorded without changing that result. Attribution uses phase, ordered lease markers and source stacks; final uninstrumented traces do not carry an end-to-end generation/request ID for every worker corpus/origin read.The repaired schema-refresh stack (
refreshOpenClawAgentDatabaseSchema) falls from median 778 → 82 statements per workload and 308 → 0 across ten warmed turns. Its warmed samples are main[185, 431, 148, 308, 317], candidate[0, 0, 0, 40, 0]. Complete SQL × normalized stack × thread × phase counts are retained for all ten runs. No new foreign freshness probe or compensating policy cache was added.Exact attribution of the rejected measurement and the correction
The rejected first-turn median was +50 statements; the rejected warmed median was +35 per turn. Exact decomposition uses the runs that supplied each overall median, rather than summing independently chosen per-stack medians. The table below reconciles +50 and +350 across ten warmed turns at the earlier measured head/base.
openClaimedWriter→refreshOpenClawAgentDatabaseSchemaComplete SQL-shape and source-site totals were retained even where the joint cross-product was not. Representative positive worker SQL shapes from that same comparison:
PRAGMA schema_versionPRAGMA table_listsqlite_schemapragma_index_list/ index definitionspragma_index_xinfoschema_metaownership/version rowA separate non-gating diagnostic at integrated
7ddec2cacec3joined transport request keys, sender stacks, native SQL and timestamps. All 25 repeateddatabase.prepareWriterequests followed TEMP cleanup on the exact canonical agent DB path; each sawschemaValid=false. Twenty-three used the normal preparation path and only two requested forced re-admission. Another 350 preparations reused valid receipts correctly. Forced re-admission was therefore retained, rather than weakened.The 25 repeated requests cost 37–40 statements each (median 40). Sender stacks identified 15 entry patches, four writable-entry preparations, two entry admissions, one deletion, two ordinary worker admissions and one queue-truncated caller. All 1,918 incognito captures were unbound. These counters establish the faulty producer and preserve attribution limits; the final uninstrumented alternating-pair results above determine gate acceptance.
Functional, review, type, SDK and build proof
pnpm test extensions/active-memory/index.test.ts --maxWorkers=1 -t 'resolves thinking and fast mode'against the pre-fix implementationpnpm testActive Memory, managed registry lifetime, SDK entry, actor history and Memory files,--maxWorkers=1pnpm test src/infra/sqlite-schema-facts.test.ts --maxWorkers=1 -t 'expires local TEMP facts'against original productionPRAGMA data_versionprobespnpm test src/infra/sqlite-schema-facts.test.ts --maxWorkers=1pnpm testMemory publication generation/transfer/settlement files,--maxWorkers=1pnpm test src/state/openclaw-agent-execution-incognito.history.test.ts src/state/openclaw-agent-execution-incognito.memory.test.ts src/plugin-sdk/session-store-runtime.async.test.ts --maxWorkers=1fe4190d23018; includes real Active Memory prompt/status, actor loss, no host SQL under binding, native unbound behavior, and durable siblingspnpm tsgo:coreafter integrationpnpm tsgo:core:testpnpm tsgo:extensions/pnpm tsgo:extensions:testpnpm plugin-sdk:surface:checkpnpm plugin-sdk:api:diff --base e69931d6e6a21b0067a9f474db50a86e9563f61e --head 90716cea3f83644f03f6c641e5151e3b204e09b58d6d5fdd: three additions, 154 reachable type changes, zero direct changes/removals, no entrypoint changesThe earlier full
pnpm buildpassed with 96 plugins, the CLI bootstrap/lazy-import guard and 53 built control-plane modules. Final QA source-map build receipts accompany the SQL proof. Prior durable transcript/SDK/Memory sibling proof passed eight files / 123 tests; ClickClack/runtime proof passed 13 files / 203 tests. Unchanged inputs retain that proof.Three original isolated P2 review rounds were clean. Fresh P1 reviews of the requested corrections were also scoped-clean; the final TEMP review included full schema, validation, delivery and entry-source authority context. No accepted P0/P1 finding remains. The only production change after the final Memory/type/lint receipts deleted an unnecessary TEMP-only read-scope reset; the final schema tests and fresh review cover that deletion. No public signature changed after the SDK comparison.
Tests explicitly cover metadata replacement across controlled awaits, by-ID identity and missing results, typed actor loss, raw off-path history, exact visible cursor/reset/requiredBytes/message limits, latest assistant with a trailing user, mirror receipts, private cleanup and durable sibling behavior. No private transcript is ingested into durable Memory storage.
Local wall times are not hosted CI cost. Hosted CI seconds/outcome remain pending until the pushed-head run completes. The published-driver × candidate update cell passed on landing head
74a74b76aedc; details below.Known inherited checks and size disposition
check:changedreports growth in existing oversized owner/test files. LOC is explicitly non-gating for this assignment; no size or timeout baseline was expanded. The native planner's remaining commands passed, including formatting, all Knip scans, types, changed-file lint, SDK surface/package exports, SQLite-worker and timeout ratchets, plugin boundaries, import cycles, schema/database-first guards, Doctor contracts, pairing and webhook guards.Seven creation-witness cases have unchanged exact-object expectations that omit
transcriptPublication, added by main's7a82a475dc23(#167875). The test, producer and publication-type blobs match both pinnede69931d6e6a2and the independently checked later mainffff5b214290. The producer unconditionally assigns the field before returning. These failures remain recorded; the expectations were not weakened or rerun merely for green.pnpm db:worker-inventory:checkreports a stale generated inventory on both pinned main and candidate. Current source inventories are 618 files, 2,428 → 2,429 calls; the single addition is the worker-to-worker latest-assistant wrapper. The TEMP correction adds no SQL access wrapper. No incognito T1 retirement is claimed.Inactive completion, released sync contract and retained native paths
These IDs are closed only for inactive implementation and the explicit-binding consumer contract. P01/P02 dependency work is not charged again. Native read/hydration/stats/watermark/presence selection, Memory entry/reset/corpus selectors, snapshot/bootstrap kernels, durable ingestion guards, and named sync/offline contracts remain. Current audience/caller preparation and channel mirror source guards stay intact.
The sync full-row getter is a shipped contract:
[email protected], published2026-10-08T09:38:01.687Z, exports it fromdist/plugin-sdk/session-store-runtime.d.ts:5;dist/agent-harness-runtime-R8dTs5zl.d.ts:6648declaresgetSessionEntry(params: SessionStoreReadParams): SessionEntry | undefined. Tagged sourcev2026.9.9(bcfc88812a35243893585dbeca87ca41b48272ca),src/plugin-sdk/session-store-runtime.ts:391, agrees. Its signature/body remain synchronous; the approved disposition is now encoded with@deprecated, a named async replacement and next-SDK-major removal. There is no Promise under the old name, blocking bridge, or full-entry authority mirror.Landing corrections and validation
Landing head:
74a74b76aedcd4a878742e4fcdd744404891eaa3. This corrects all three actionable findings from the completed ClawSweeper review offe4190d23018, plus the cold-history regression found in CI run 37999246325.ClickClack retains its declared
>=2026.9.9host contract: choose the async capability when present, otherwise the released synchronous getter. An available async reader's rejection propagates without a synchronous retry. Active Memory requestsorderBy: "updatedAt"through the existing async by-ID owner; default generic reads preserve exact-ID-first listing order. The opt-in includes trimmed legacy aliases and stable session-key ties. TEMP-only changes preserve MAIN admission, while revocation fixtures now execute actual MAIN DDL. Recent channel-history reads again restore cold transcripts under the retained source assertion.Released SDK audit: both
v2026.9.9and latest available tagv2026.10.1-beta.2retain synchronousgetSessionEntrysignatures; the two new async methods do not exist in those tags. The optional selection parameter extends only this PR's unreleased async API; no additional export, new environment name, schema, or migration is introduced.Focused validation passed 329 tests in ten files / seven shards, 477.37s command wall time, covering the real durable/incognito SDK reader, generic canonical reads, Active Memory, ClickClack service, schema facts and validation custody, guarded channel history, runtime-process build graph, wrapper import inventory, and get-reply import closure. Negative controls failed on the intended older-session and missing-released-host-capability defects. Test typechecking exposed one widened fixture literal, corrected with its actual
InternalSessionEntrytype; all 27 core test graphs now pass, as do core and extension production/test types. Both fresh isolated P2 correction reviews are scoped-clean; the only subsequent test edit supplied that concrete fixture type, and the commit hook formatted the ClickClack table-driven test.Measured focused suite wall times: validation-cache 45.12s, SDK/schema/guarded-history group 75.12s, canonical reads 20.69s, Active Memory 103.45s, ClickClack 87.33s, import/build graph group 13.84s, wrapper closure 55.24s. Worker compilation and transform costs are included. Current-head CI used 17,047 summed job wall seconds across 108 jobs (parallel elapsed time is lower). Targeted lint passes except the previously recorded non-gating 700-line owner-file limit in
session-entry-read-runtime.ts; no limit baseline was expanded.The earlier five alternating SQL pairs remain valid under the authorized proof-reuse rule. These corrections preserve the normal workload's emitted SQL paths; the changed optional ID-selection query is exercised directly by the focused owner regression. No SQL remeasurement was performed at landing.
Historical CI classification: TEMP revocation fixtures and cold-history preparation were PR-caused and are repaired here. The plugin-cron fallback failure (
Model prompt projection must be captured before provider dispatch) originates in main's6461c186e518(#167938). The test and five implicated prompt/fallback source blobs are identical across the tested baseline87d3db2aea6a, merge3a896554d18e, and independently inspected main; this PR does not change them. Current-head CI is run 38006222773. Current-head CI completed with one inherited root failure in unchanged plugin-cron fallback code (job114075870784) and aggregate114077921067; there were no cancellations. Native admin evidence binds tested merge184477ae0b2a7eef2c2c62c879b78a1f8d2bc0e8and baselined2643069b48d353f29db7e67993eab20330bace5.Final SDK comparison against the pinned source base completed with digest
af697948: exactly three added exports, 154 reachable type changes, zero removals or direct changes, and no entrypoint changes. The released-signature audit above remains unchanged.The published-driver update proof passed from published
[email protected]to exact candidate74a74b76aedcd4a878742e4fcdd744404891eaa3. Full package build and integrity verification passed. The update completed in 193.871s; readiness returned 200, the updater recordedfinished, the serving candidate was verified, durable history survived, and incognito history/artifacts did not survive. Full remote package/build/cell command: 698.563s; Testbox execution: 712.788s. No migration or schema bump is introduced by this PR.Worker-cutover routing audit additionally selected
src/auto-reply/reply/commands-tts.test.ts, whose real latest-history reads reach the changed reader. All 14 tests passed (433.68s including cold compilation); no new worker routing is needed. The remaining direct consumers are already worker-routed, forked, or intentionally mock this boundary.