Skip to content

fix(subagents): subagent list building decodes unrelated saved prompts in large session stores - #139540

Merged
steipete merged 2 commits into
openclaw:mainfrom
LiuwqGit:feat/issue-139518-subagent-list-metadata-projection
Sep 6, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
LiuwqGit:feat/issue-139518-subagent-list-metadata-projection

Conversation

@LiuwqGit

@LiuwqGit LiuwqGit commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Building a subagent list reads complete session records even though the list only uses metadata. In a large store, every nonempty list repeatedly decodes unrelated saved skill prompts and system-prompt reports, adding CPU and allocation work to the tool, native /subagents command, and active-subagent context.

Why This Change Was Made

Select the existing list projection at the common list reader. The accessor already removes the two unused payload fields before JavaScript allocation and owns metadata caching. Model, token, status, child metadata, visibility, full reads, and cache invalidation keep their existing contracts.

Production is +3/−4, net −1 line. The regression is consolidated into the existing real-SQLite list suite, reusing its fixture ownership and writer helper instead of adding another test module. It checks visible model/status/usage before asserting zero unrelated prompt decoding. Tests are +76/−1.

Evidence

  • Verified baseline: the actual subagents tool read a real SQLite store with 1,000 unrelated 8 KiB skill prompts and valid report metadata. First, warm-default, and post-write lists each decoded all 1,000 unrelated row strings; complete output, visibility, empty-list, full-read and metadata-update controls passed before the intended zero-decoding assertion failed.
  • Verified candidate: the consolidated regression first failed on old production with exactly 20 unrelated decodes. With the fix, the real tool decoded zero unrelated prompt/report payloads and returned identical complete output for all four list scenarios. Full reads still returned and decoded both saved fields; a normal metadata write remained visible to the next list.
  • All 37 tests passed across the full list, active-subagent context, and subagents-tool suites, with no failures or skips. Final production/test hashes match the reviewed candidate.
  • Separate uninstrumented hosted samples measured first-list calls of 190 ms before and 154 ms after, and 25 warm calls totaling 1.017 s before and 0.710 s after. RSS before/after those calls was 782.375→789.5 MiB in the baseline process and 808.074→818.695 MiB in the candidate process. These are separate samples, without thresholds or a general speed/memory-improvement claim.
  • The first proof attempt failed a fixture expectation: an ended child without recorded cleanup completion still counts as pending. The exact expected status/count/text was corrected to the pinned existing contract; no production or seeded state changed, and that failed run is not counted as a decoding baseline.
  • Fresh committed-head autoreview, separate source/evidence review and independent actual-proof verification found no actionable findings. Required CI passed at f174e9c80eacc7811c4d80622a4def50c4ac5b9e.

Original contribution by @LiuwqGit, preserved in branch ancestry and human coauthor credit. This repairs the remaining common list reader; previously merged reconciliation/depth and sessions-tail changes are not included or counted again.

@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 agents Agent runtime and tooling size: S 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:15 PM ET / 18:15 UTC.

ClawSweeper review

What this changes

Subagent lists use the existing session metadata projection to avoid decoding unused saved prompts, with a regression test preserving model, status, and token output.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: fetched main and the latest release still perform full reads in the common subagent-list reader. The focused repair has credible production-path proof and no actionable correctness findings.

Priority: P2
Reviewed head: f174e9c80eacc7811c4d80622a4def50c4ac5b9e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair using an established accessor contract, supported by real production-path results and a meaningful regression test.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Supplied production-tool runs exercise the changed list builder against real SQLite stores and report zero unrelated prompt decodes with identical output, preserved full reads, and visible metadata updates; linked hosted logs could not be independently fetched.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Supplied production-tool runs exercise the changed list builder against real SQLite stores and report zero unrelated prompt decodes with identical output, preserved full reads, and visible metadata updates; linked hosted logs could not be independently fetched.
Evidence reviewed 9 items Current main still needs the repair: The common reader still calls listSessionEntriesReadOnly without a projection, which defaults to full reads.
Latest release retains the full reader: The supplied latest release, v2026.9.2, also omits the list projection at this call site.
Projection preserves the consumed metadata: The existing SQL projection removes skillsSnapshot and systemPromptReport before JavaScript allocation. Neither field is consumed by the list builder or its token-formatting helpers; identity, model, usage, and ownership metadata remain available.
Findings None None.
Security None None.

How this fits together

The subagent-list builder combines controlled runs with saved session metadata. Its output feeds the subagents tool, native list command, and active-subagent prompt context.

flowchart TD
  A[Controlled subagent runs] --> D[Common list builder]
  B[SQLite session records] --> C[Existing metadata projection]
  C --> D
  D --> E[Tool list results]
  D --> F[Native list command]
  D --> G[Active subagent context]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -1, Tests +75. Total +74 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 4 -1
Tests 1 76 1 +75
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 79 5 +74

Review metrics

None.

Technical review

Best possible solution:

Keep the common list reader on the existing metadata projection while preserving output, full-read behavior, and canonical cache invalidation.

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

Yes: current main defaults this reader to full records, and the supplied real-SQLite runs demonstrate unrelated prompt decoding. This review verified the source path without executing it.

Is this the best way to solve the issue?

Yes: selecting the existing projection at the shared reader is a narrow repair that preserves listing semantics and avoids a competing reader or cache.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repeated unnecessary prompt decoding slows subagent listings in large session stores without evidence of data loss or an urgent outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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): Supplied production-tool runs exercise the changed list builder against real SQLite stores and report zero unrelated prompt decodes with identical output, preserved full reads, and visible metadata updates; linked hosted logs could not be independently fetched.
  • proof: sufficient: Contributor real behavior proof is sufficient. Supplied production-tool runs exercise the changed list builder against real SQLite stores and report zero unrelated prompt decodes with identical output, preserved full reads, and visible metadata updates; linked hosted logs could not be independently fetched.

Evidence

What I checked:

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 (2 earlier review cycles)
  • reviewed 2026-09-06T00:12:47.685Z sha 8483ef4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-06T10:22:39.542Z sha 8483ef4 :: needs maintainer review before merge. :: none

@obviyus obviyus assigned obviyus and unassigned obviyus Sep 6, 2026
@LiuwqGit

LiuwqGit commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Real behavior proof added for the review's outstanding items — the changed listing path is now demonstrated in a running production flow, with before/after seconds and RSS.

What was run (no mocks, no vitest): a standalone Node process drives the production subagents tool end to end — createSubagentsTool(...).execute("", { action: "list" }) → controller resolution → controlled-run read from the real SQLite subagent registry (seeded through the production persistence API saveSubagentRegistryToSqlite) → shared list builder → listSessionEntriesReadOnly — against a real on-disk SQLite session store (temp OPENCLAW_STATE_DIR, seeded via the production writer replaceSessionEntrySync) holding 1,000 unrelated sessions with 8 KiB skillsSnapshot.prompt payloads each plus the one target child session. The identical driver ran against the pre-fix reader (parent commit state of src/agents/subagents/registry/subagent-list.ts) and this PR head.

Results (25 production list calls):

Metric Before (pre-fix reader) After (this PR)
Unrelated prompt payload JSON.parse calls 26,000 (all 1,000 rows decoded per list) 0
Total wall time 0.635 s 0.043 s
Mean per list 25.41 ms 1.72 ms (~14.8×)
RSS delta across measured loop +10.8 MB +0.5 MB
Output contract (status: ok, total: 1, target run/session keys, totalTokens: 197000, usage line 197k) identical identical

Both runs return byte-identical list output (model/token metadata lines unchanged), so the projection selection changes only what is decoded, not what is listed.

The PR body's Evidence section has been updated with the same numbers and the exact commands. What remains untested (noted honestly in the body): no full Gateway daemon/agent turn — the proof exercises the production tool path in-process against real SQLite files, which is the exact changed listing path; timing is from a local dev machine and indicative, not benchmark-grade.

@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
@steipete steipete self-assigned this Sep 6, 2026
Keep the metadata allocation regression beside the existing real-SQLite list
coverage, sharing its workspace and canonical session writer. Preserve visible
model, token and status assertions before checking unrelated prompt decoding.

The existing list projection repair avoids decoding unused saved prompts.
Secretless hosted proof confirms the intended baseline failure, zero unrelated
payload decodes after the fix, complete tool-output parity, and 37 passing tests.

Co-authored-by: LiuwqGit <[email protected]>
@steipete
steipete merged commit 66cf9a1 into openclaw:main Sep 6, 2026
215 of 217 checks passed
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 6, 2026
* origin/main: (25 commits)
  docs(releases): keep the release-notes nav group to version routes (#140353)
  fix(ui): hide trust wrappers in imported chat history
  fix(subagents): subagent list building decodes unrelated saved prompts in large session stores (#139540)
  test(process): share relay startup fixtures (#140345)
  refactor(doctor): inline GitHub skill discovery inputs (#140343)
  refactor(ui): share channel status type definitions (#140331)
  refactor: simplify queue state and infrastructure dispatch (#140311)
  fix: require saved agent turns before update verification succeeds (#140274)
  fix(update): keep the service profile when switching to Git (#140263)
  fix(ui): prevent image avatars overlapping mobile chat (#140341)
  fix(test): accept release subpages in docs route shape (#140337)
  refactor(plugins): share uninstall mutation ownership (#140322)
  refactor(agents): use canonical tool execution arguments (#140280)
  perf(cli): keep inference metadata and domain help lazy (#140327)
  refactor(plugins): simplify self-hosted setup results (#140332)
  refactor(config): reuse parent lookup for unset operations (#140326)
  fix(plugins): preserve exact installed-index mutation receipts (#140328)
  test(agents): simplify MCP and LSP boundary fixtures (#140312)
  fix(ui): preserve literal source previews and copied whitespace (#140306)
  fix: OpenCode Go/Zen requests are missing the required x-opencode-session header (#137464)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…s in large session stores (openclaw#139540)

* fix(subagents): subagent list building decodes unrelated saved prompts in large session stores

* test(subagents): consolidate list metadata regression

Keep the metadata allocation regression beside the existing real-SQLite list
coverage, sharing its workspace and canonical session writer. Preserve visible
model, token and status assertions before checking unrelated prompt decoding.

The existing list projection repair avoids decoding unused saved prompts.
Secretless hosted proof confirms the intended baseline failure, zero unrelated
payload decodes after the fix, complete tool-output parity, and 37 passing tests.

Co-authored-by: LiuwqGit <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: LiuwqGit <[email protected]>
@LiuwqGit
LiuwqGit deleted the feat/issue-139518-subagent-list-metadata-projection branch September 22, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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.

3 participants