Skip to content

fix(cli): keep sessions tail responsive in large stores - #139730

Merged
obviyus merged 2 commits into
openclaw:mainfrom
ly85206559:codex/fix-sessions-tail-metadata
Sep 6, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
ly85206559:codex/fix-sessions-tail-metadata

Conversation

@ly85206559

@ly85206559 ly85206559 commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #139671

What Problem This Solves

Fixes an issue where operators tailing a session decoded saved prompts from unrelated sessions before seeing progress. Automatic running/latest selection also reread session entries while checking agent-runtime activity.

Why This Change Was Made

Use the existing session metadata projection, then pass the selected entry to the existing agent-runtime metadata reader. Keep its owner resolution and session-generation checks. Full readers still return complete saved prompts. This adds no query, cache, schema, or selection policy.

User Impact

Explicit and automatic tailing avoid unrelated saved-prompt decoding while preserving selected sessions, output, read-only access, and follow behavior.

Evidence

  • Built CLI comparison against main e19a7694cef6d38140033f798215103dd638fafb: explicit-key unrelated parses fall from 100 to 0 at 100 rows and 500 to 0 at 500 rows. Latest selection falls from 200 to 0 at 100 rows. Selected output is byte-for-byte unchanged.
  • Increasing each saved field from 4 KiB to 64 KiB keeps the candidate count at zero.
  • 33 paired CLI controls preserve selection/order, malformed/deep/NUL/canonical-key behavior, database contents/data version, and current/stale runtime identity binding across two agents.
  • 90 focused tests pass. All four regression modes fail on main with 100 or 200 unrelated parses; the candidate passes. Targeted type-aware lint and formatting pass.
  • Fresh source-blind acceptance passes all ten observable clauses, including complete full readers and eight follow runs across both builds, explicit/latest selection, and tail counts 0/1. Internal SQLite allocation is not measured.

Thirty-one alternating measured pairs per store size, after two warmups per build, on the same isolated Linux/Node 24.20.0 runtime. Timing uses no JSON parse spy.

Unrelated rows Main/candidate median wall Main/candidate median CPU Main/candidate median peak memory
100 1538 / 1551 ms 2038 / 2046 ms 420244 / 420992 KiB
500 1530 / 1537 ms 2034 / 2031 ms 421380 / 420856 KiB

The 500-row CPU median is 3.416 ms lower (0.17%). This is too small to establish a reliable speedup; neither general latency nor memory reduction is claimed. The measured work reduction is elimination of unrelated prompt decoding.

Original contribution by @ly85206559, with expanded repair, regression coverage, and CLI proof.

@clawsweeper

clawsweeper Bot commented Sep 6, 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 commands Command implementations size: XS labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 2:58 AM ET / 06:58 UTC.

ClawSweeper review

What this changes

Session progress tailing uses existing lightweight metadata readers to avoid decoding unrelated saved prompts while preserving session selection and output.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main and addresses the linked issue without duplicating the adjacent merged fixes. No blocking correctness or security findings remain, and the supplied CLI observations adequately demonstrate reduced decoding work.

Priority: P2
Reviewed head: 05caa5e907a85b51dac628473de0c968c81d245d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with substantial real CLI observations, useful regression coverage, and no supported blocking findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied compiled-CLI observations exercise tail selection on isolated Linux SQLite stores and show zero unrelated prompt decodes with unchanged output, identity binding, database state, and follow behavior; they do not establish a reliable end-to-end speedup.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied compiled-CLI observations exercise tail selection on isolated Linux SQLite stores and show zero unrelated prompt decodes with unchanged output, identity binding, database state, and follow behavior; they do not establish a reliable end-to-end speedup.
Evidence reviewed 8 items Verified introduced scope: The merge-base-to-head diff contains only the tail command and its regression tests, matching the host's complete introduction evidence. Base-branch drift was excluded from the review.
Current main and release still need the fix: Inspected current main and v2026.9.2: both omit the list projection and use readAcpSessionMeta, which rereads the session entry. Neither contains this tail-specific repair.
Existing projection preserves required metadata: The existing list projection removes skillsSnapshot and systemPromptReport while retaining selection and lifecycle fields. Listing still uses the same visibility, canonical-key, and malformed-row handling; full readers remain unchanged.
Findings None None.
Security None None.

How this fits together

The sessions tail CLI selects stored conversations, reads their recorded runtime events, and prints progress. Session metadata determines which conversations are selected; follow mode then watches their SQLite trajectory rows.

flowchart TD
  A[CLI options] --> B[Resolve agent stores]
  B --> C[Read lightweight session metadata]
  C --> D[Select explicit, running, or latest sessions]
  E[Runtime activity metadata] --> D
  D --> F[Read recorded trajectory events]
  F --> G[Print and follow progress]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +9, Tests +89. Total +98 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 16 7 +9
Tests 1 90 1 +89
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 106 8 +98

Review metrics

Metric Value Why it matters
Measured decoding reduction 100/500 unrelated explicit-selection decodes → 0 The compiled CLI comparison demonstrates eliminated work, while its timing measurements do not establish a general speedup.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #139671
Summary: This PR directly addresses the open tail-selection issue; adjacent merged optimizations do not supersede 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 tail selection on the existing metadata-only path while preserving full readers, runtime generation checks, and trajectory-follow behavior.

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

Yes. Current main selects sessions through full-store reads, and the supplied real-store CLI comparison demonstrates unrelated prompt decoding; this review verified the source path without executing it.

Is this the best way to solve the issue?

Yes. Reusing the existing projection and entry-aware runtime reader is a narrow repair that avoids new queries, caches, schemas, or selection policies.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This removes avoidable work in a diagnostic CLI command with large session stores, without an established urgent runtime outage.
  • 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): The supplied compiled-CLI observations exercise tail selection on isolated Linux SQLite stores and show zero unrelated prompt decodes with unchanged output, identity binding, database state, and follow behavior; they do not establish a reliable end-to-end speedup.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied compiled-CLI observations exercise tail selection on isolated Linux SQLite stores and show zero unrelated prompt decodes with unchanged output, identity binding, database state, and follow behavior; they do not establish a reliable end-to-end speedup.

Evidence

What I checked:

  • Verified introduced scope: The merge-base-to-head diff contains only the tail command and its regression tests, matching the host's complete introduction evidence. Base-branch drift was excluded from the review. (src/commands/sessions-tail.ts:167, 05caa5e907a8)
  • Current main and release still need the fix: Inspected current main and v2026.9.2: both omit the list projection and use readAcpSessionMeta, which rereads the session entry. Neither contains this tail-specific repair. (src/commands/sessions-tail.ts:299, a089d4e11aaf)
  • Existing projection preserves required metadata: The existing list projection removes skillsSnapshot and systemPromptReport while retaining selection and lifecycle fields. Listing still uses the same visibility, canonical-key, and malformed-row handling; full readers remain unchanged. (src/config/sessions/session-accessor.sqlite-status.ts:31, 05caa5e907a8)
  • Runtime generation binding remains enforced: The selected entry reaches the existing read-only runtime metadata reader. Its shared matching logic retains lifecycle-revision, session-ID, and session-start-time checks; existing tests cover legacy bindings and stale generations. This is an OpenClaw metadata contract, with no affirmative dependency on the Codex harness. (src/acp/runtime/session-meta-keys.ts:130, 05caa5e907a8)
  • Focused regression coverage: The added table exercises explicit, running, latest, and runtime-active selection through the command using real SQLite rows. It checks zero unrelated payload decodes and selected output. The supplied body reports all four cases failing before the fix and 90 focused tests passing afterward; this review did not execute tests. (src/commands/sessions-tail.test.ts:342, 05caa5e907a8)
  • After-fix compiled CLI observations: The complete supplied PR body reports isolated Linux/Node 24.20.0 compiled-CLI comparisons: explicit selection reduces unrelated decodes from 100/500 to zero, latest selection from 200 to zero, and output remains byte-identical. It also reports 33 paired selection/storage/identity controls and eight follow runs. Uninstrumented timing does not establish a reliable latency or memory improvement. Captured context sourceRevision: 7af8adce947ca0701c32dc8b3b812805e4bcc54d9a6fb502e8222ad211bbf5db. (05caa5e907a8)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • ToToKr: 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 (2 earlier review cycles)
  • reviewed 2026-09-06T04:28:38.870Z sha 1411d0a01d530b416682925b297558f8c3603ca8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-06T04:51:22.589Z sha 1411d0a01d530b416682925b297558f8c3603ca8 :: needs maintainer review before merge. :: none

@ly85206559

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

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 Sep 6, 2026
@obviyus obviyus self-assigned this Sep 6, 2026
ly85206559 and others added 2 commits September 6, 2026 08:32
Use the existing metadata projection when selecting sessions to tail. Preserve selection and trajectory rendering while excluding unrelated saved prompt payloads. Extend the regression to cover both saved fields and selected output.
Use the existing ACP metadata reader with the selected session generation and existing owner resolution. Avoid a second full session read during running/latest selection, and cover explicit, running, latest, and ACP-driven selection with unrelated saved prompts.
@obviyus
obviyus force-pushed the codex/fix-sessions-tail-metadata branch from 1411d0a to 05caa5e Compare September 6, 2026 06:52
@obviyus
obviyus merged commit c11192a into openclaw:main Sep 6, 2026
112 of 113 checks passed
@obviyus

obviyus commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks @ly85206559! Merged as c11192a, with your contribution preserved.

Bug: tail selection decoded saved prompts from unrelated sessions; automatic selection also reread session entries during runtime activity checks.

Fix: reuse the existing metadata projection and selected session identity, retaining owner and session-generation checks.

Proof: built CLI against synthetic SQLite stores, 90 focused tests, independent behavior acceptance, and a clean exact-head local review. Exact-head CI passed; no CI exception was used.

Scenario Before: unrelated parses After
Explicit key, 100 unrelated rows 100 0
Explicit key, 500 unrelated rows 500 0
Latest selection, 100 unrelated rows 200 0

Output, selection order, malformed-row errors, stale runtime bindings, full readers, and read-only state are preserved. Eight follow probes emit each appended event once.

All ten observable acceptance clauses pass. The 31-pair timing comparison has only a 3.416 ms lower CPU median at 500 rows, so it does not establish a reliable speedup or general memory reduction. Internal SQLite allocation was not measured.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
Use the existing session metadata projection and reuse the selected session identity for agent-runtime activity checks. Avoid unrelated saved-prompt decoding in explicit and running/latest tail selection while preserving trajectory output and session-generation validation.

Closes openclaw#139671. Preserve the original contribution by @ly85206559 and expand regression coverage across all selection modes.

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
@ly85206559
ly85206559 deleted the codex/fix-sessions-tail-metadata branch October 5, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

Sessions tail decodes unrelated saved prompts in large session stores

2 participants