Skip to content

fix(ai-vault): group OMP task subagent transcripts under their parent session - #12803

Merged
Jinwoo-H merged 4 commits into
stablyai:mainfrom
dcieslak19973:dcieslak19973/omp-subagent-history
Aug 6, 2026
Merged

Jinwoo-H merged 4 commits into
stablyai:mainfrom
dcieslak19973:dcieslak19973/omp-subagent-history

Conversation

@dcieslak19973

Copy link
Copy Markdown
Contributor

What: OMP task-worker transcripts no longer flood Agent Session History as top-level rows — they're pruned from the scan, counted on their coordinator's row, and listed on demand under it, exactly like Claude's subagents since #7423.
Risk: Additive per-agent branches on existing seams; Claude behavior byte-identical (its partition/count/lister untouched, suites green); Pi/OpenClaw skip the new readdir explicitly.
State: Based on today's main; tsc/lint clean; 8 new tests; ai-vault + IPC suites green.


Fixes #9330. Implements the issue's suggested direction 1–5:

  1. Classify by the nested artifact path — OMP persists task-child transcripts inside the parent session's same-named artifact directory (…/<workspace>/<stamp>_<uuid>.jsonl + …/<workspace>/<stamp>_<uuid>/<TaskLabel>.jsonl). The rigid <ISO-stamp>_<uuidv7> dir-name pattern is the classification signal.
  2. Excluded from top-level candidates — discovery prunes artifact-dir subtrees via the same directoryPredicate seam Claude uses for subagents/.
  3. Count attached to the parent row — local parses readdir the artifact dir at finalize (mirrors finalizeClaudeSessionParseState); remote SSH walks partition their listing instead, so no extra round-trips. Zero-turn cache reuse refreshes the count, matching Claude.
  4. Parsed/listed only on demand — the existing aiVault:listSubagentSessions IPC now accepts omp, with the same renderer-supplied-path allowlist posture (new ompSessionsRootDirs). The renderer needed zero changes — it was already agent-agnostic behind the count.
  5. Genuine top-level forks preserved — classification is purely structural, never parentSession, per the issue's warning that lineage alone is insufficient evidence.

Children are titled by their coordinator-given task label (the transcript filename stem — the analog of Claude's meta.description) and linked to the layout-derived parent id, so a child with no session record of its own still lands under the right parent.

Changes

  • src/main/ai-vault/session-scanner-omp-subagents.ts (new) — artifact-dir name pattern, direct-child count, remote-walk partition, and the parse-state decorator that attaches the count for local parses only.
  • src/main/ai-vault/session-scanner-omp-subagent-listing.ts (new) — on-demand child lister (separate module so the graph parser can import the count decorator without a parser↔lister cycle).
  • src/main/ai-vault/session-scanner-source-discovery.ts — prune predicate on the OMP discovery.
  • src/main/ai-vault/session-scanner-graph-parsers.ts — OMP resume state wrapped with the count decorator; Pi/OpenClaw untouched.
  • src/main/ai-vault/session-scanner-parse-cache.ts — zero-turn reuse recount extended from Claude-only to Claude+OMP.
  • src/main/ai-vault/remote-session-scanner-{types,discovery,sources}.ts — collectSubagentSiblingCounts: boolean generalized to an explicit per-source partitionSubagentTranscripts function; Claude keeps its partition, OMP gets its own.
  • src/main/ipc/ai-vault.ts — subagent-listing gate accepts claude | omp, roots resolved per agent.
  • src/main/ai-vault/session-scanner-roots.ts (new) — extracted home of claudeProjectsRootDirs/ompSessionsRootDirs (the renderer-supplied-path allowlists), keeping discovery and the IPC module under the lint line caps without weakening them.

Tests

  • session-scanner-omp-subagents.test.ts — dir-name pattern boundaries, direct-child-only counting (nested local/ artifacts excluded), remote partition on posix and Windows separators, grandchild transcripts attribute to their nearest parent and never surface as candidates.
  • session-scanner-omp-subagent-prune.test.ts — scan-level mirror of the Claude prune test: coordinator surfaces as the only row with subagentTranscriptCount attached.
  • session-scanner-omp-subagent-listing.test.ts — children listed newest-first, titled by task label, linked to the layout-derived parent id; never-delegated sessions resolve empty.

Verified against a real OMP store

A coordinator session that spawned 6 task workers went from 7 top-level history rows to 1 — the coordinator row now carries a "6 subagents" count and expanding it lists all 6 children by task label, each linked to the parent session id.

… session

OMP persists task-child transcripts inside the parent session's same-named
artifact directory (<stamp>_<uuid>/), and discovery scanned them as ordinary
top-level sessions - a coordinator's history drowned under its own workers.

Extend the existing Claude subagent model to OMP, classifying purely by the
artifact-dir layout (never by a transcript's parentSession field, which also
describes non-task lineage):

- prune artifact dirs from the top-level scan (name-pattern predicate)
- count direct-child transcripts onto the parent row (local readdir; remote
  walks partition their listing instead, mirroring Claude's SSH posture)
- list children on demand via the existing listSubagentSessions IPC, titled
  by their coordinator-given task label and linked to the layout-derived
  parent id
- refresh the count on zero-turn cache reuse, matching Claude
- extract session-scanner-roots.ts so the renderer-supplied-path allowlist
  for both agents lives in one module

Fixes stablyai#9330
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds OMP subagent transcript discovery, counting, partitioning, pruning, and on-demand listing. Shared session-root utilities now support Claude, OMP, and WSL paths. Remote sources use provider-specific partition callbacks. OMP artifact directories are excluded from top-level session discovery. IPC validation and dispatch now support OMP subagent sessions. Cache and resume-state logic refresh OMP subagent counts. Tests cover local, remote, nested, malformed, and dynamically created transcripts.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and tests, but it omits the required AI Review Report, Security Audit, Notes, and explicit Screenshots section. Add all missing template sections, complete the testing checklist, and document the AI review, security audit, platform checks, and visual-change status.
Docstring Coverage ⚠️ Warning Docstring coverage is 43.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes grouping OMP task subagent transcripts under their parent session, which is the primary change.
Linked Issues check ✅ Passed The changes satisfy issue #9330 by pruning OMP task transcripts, counting and listing them under parents, preserving top-level forks, and supporting local and remote scans.
Out of Scope Changes check ✅ Passed The implementation, tests, shared fixtures, root utilities, and IPC updates directly support the OMP subagent grouping objectives.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…anches

Prune predicate now skips depth 0 (the workspace dir), so a workspace whose
name happens to look like a session stem keeps its sessions. Drop degenerate
OMP roots in ompSessionsRootDirs: OMP_CODING_AGENT_DIR='/' normalizes to '',
which resolve()s to the process cwd and would have allowlisted it for the
renderer-supplied subagent path.

Rename session-scanner-omp-subagents.ts to -omp-subagent-transcripts.ts so it
mirrors Claude's transcripts/lister split by role rather than inverting it.

Correct two comments that asserted things the codebase contradicts: OMP task
children do carry their own sessionId and would resume by path (OMP's own
picker globs `*/*.jsonl`, so it never offers them either), and workspace dir
names are not uniformly dash-prefixed.

Cover branches the change added with no test: the remote/SSH partition wiring,
the IPC `omp` gate and per-agent allowlist, the parse-cache zero-turn recount,
and the executionHostId disk-ownership guard. Extract the remote scanner's
in-memory provider into a fixtures module to stay under the max-lines cap.

@Jinwoo-H Jinwoo-H left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this — the direction is right and the reasoning in the description held up under scrutiny.

I reproduced the issue end-to-end against a real OMP 17.2.9 store rather than reviewing the diff alone: a coordinator that delegated 3 tasks showed 11 top-level OMP rows on main (7 of them worker transcripts) vs 4 on this branch, with the coordinator carrying its count and expanding to list children by task label.

Two things that made me confident in the classification rule specifically:

  • OMP's own bug-report bundler defines subagents as exactly "every *.jsonl directly inside <parentStem>/" — the same rule this implements. Spilled tool artifacts are always <id>.<label>.log, so they can't inflate the count.
  • OMP's own session picker globs */*.jsonl, one level deep, so it never offers these transcripts for resume either.

I also seeded a grandchild transcript, a local/ dir, a spilled .log, and a /tan fork into a real store — all classified correctly, and the badge count matched the expanded list in every case.

I pushed four review commits on top of yours:

  • Security-relevant: OMP_CODING_AGENT_DIR='/' normalizes to '', which resolve()s to the process cwd — that would have silently allowlisted it for the renderer-supplied subagent path. Inert before, but this PR is what wires that constant into the IPC gate. Guarded in ompSessionsRootDirs.
  • Hardening: the prune predicate now skips depth 0, so a workspace directory whose name happens to look like a session stem keeps its sessions.
  • Naming: renamed the primitives module to session-scanner-omp-subagent-transcripts.ts so it mirrors Claude's transcripts/lister split by role rather than inverting it (Claude's -subagents.ts is the lister).
  • Comments: corrected two that asserted things the codebase contradicts — notably that OMP task children "aren't independently resumable." They carry their own session id and ai-vault-resume-command.ts resumes them by path. The prune is still right, just for a different reason.
  • Coverage for six branches the change added with no test — the remote/SSH partition wiring, the IPC omp gate, the parse-cache zero-turn recount, and the executionHostId disk-ownership guard. Two of those mutations were surviving silently.

Two carve-outs worth naming, since they're accepted rather than fixed: OMP task children lose an obscure resume path (they were resumable by file path; the row is view-only now), and grandchild transcripts become unreachable in the UI. I'm filing a follow-up to make subagent rows resumable, which closes both — the renderer already receives everything it needs and discards it.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/ipc/ai-vault.test.ts (1)

645-654: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert that both provider listers remain unused.

Line 645 checks only listOmpSubagentSessions. A regression could call listClaudeSubagentSessions for the remote OMP request without failing this test.

Line 656 has the same gap for the cross-agent and traversal requests. Add a Claude no-call assertion after each test.

Proposed test strengthening
     expect(mocks.listOmpSubagentSessions).not.toHaveBeenCalled()
+    expect(mocks.listClaudeSubagentSessions).not.toHaveBeenCalled()
...
     expect(mocks.listOmpSubagentSessions).not.toHaveBeenCalled()
+    expect(mocks.listClaudeSubagentSessions).not.toHaveBeenCalled()

Also applies to: 656-673


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bb10be1b-935f-4350-924d-bc1f84f3ccd1

📥 Commits

Reviewing files that changed from the base of the PR and between fb3bd73 and 89a984d.

📒 Files selected for processing (14)
  • src/main/ai-vault/remote-session-scanner-omp-subagents.test.ts
  • src/main/ai-vault/remote-session-scanner-sources.ts
  • src/main/ai-vault/remote-session-scanner-test-fixtures.ts
  • src/main/ai-vault/remote-session-scanner.test.ts
  • src/main/ai-vault/session-scanner-graph-parsers.ts
  • src/main/ai-vault/session-scanner-omp-subagent-listing.ts
  • src/main/ai-vault/session-scanner-omp-subagent-prune.test.ts
  • src/main/ai-vault/session-scanner-omp-subagent-transcripts.test.ts
  • src/main/ai-vault/session-scanner-omp-subagent-transcripts.ts
  • src/main/ai-vault/session-scanner-parse-cache.ts
  • src/main/ai-vault/session-scanner-roots.test.ts
  • src/main/ai-vault/session-scanner-roots.ts
  • src/main/ai-vault/session-scanner-source-discovery.ts
  • src/main/ipc/ai-vault.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/main/ai-vault/session-scanner-parse-cache.ts
  • src/main/ai-vault/remote-session-scanner-sources.ts
  • src/main/ai-vault/session-scanner-source-discovery.ts
  • src/main/ai-vault/session-scanner-omp-subagent-listing.ts
  • src/main/ai-vault/session-scanner-graph-parsers.ts

@Jinwoo-H
Jinwoo-H merged commit b5ad2ac into stablyai:main Aug 6, 2026
43 checks passed
@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… session (stablyai#12803)

* fix(ai-vault): group OMP task subagent transcripts under their parent session

OMP persists task-child transcripts inside the parent session's same-named
artifact directory (<stamp>_<uuid>/), and discovery scanned them as ordinary
top-level sessions - a coordinator's history drowned under its own workers.

Extend the existing Claude subagent model to OMP, classifying purely by the
artifact-dir layout (never by a transcript's parentSession field, which also
describes non-task lineage):

- prune artifact dirs from the top-level scan (name-pattern predicate)
- count direct-child transcripts onto the parent row (local readdir; remote
  walks partition their listing instead, mirroring Claude's SSH posture)
- list children on demand via the existing listSubagentSessions IPC, titled
  by their coordinator-given task label and linked to the layout-derived
  parent id
- refresh the count on zero-turn cache reuse, matching Claude
- extract session-scanner-roots.ts so the renderer-supplied-path allowlist
  for both agents lives in one module

Fixes stablyai#9330

* review: harden OMP subagent classification and cover its uncovered branches

Prune predicate now skips depth 0 (the workspace dir), so a workspace whose
name happens to look like a session stem keeps its sessions. Drop degenerate
OMP roots in ompSessionsRootDirs: OMP_CODING_AGENT_DIR='/' normalizes to '',
which resolve()s to the process cwd and would have allowlisted it for the
renderer-supplied subagent path.

Rename session-scanner-omp-subagents.ts to -omp-subagent-transcripts.ts so it
mirrors Claude's transcripts/lister split by role rather than inverting it.

Correct two comments that asserted things the codebase contradicts: OMP task
children do carry their own sessionId and would resume by path (OMP's own
picker globs `*/*.jsonl`, so it never offers them either), and workspace dir
names are not uniformly dash-prefixed.

Cover branches the change added with no test: the remote/SSH partition wiring,
the IPC `omp` gate and per-agent allowlist, the parse-cache zero-turn recount,
and the executionHostId disk-ownership guard. Extract the remote scanner's
in-memory provider into a fixtures module to stay under the max-lines cap.

* review: note why child rows carry an unrendered grandchild count

* review: describe the real OMP grandchild layout in the pattern comment

---------

Co-authored-by: Dan Cieslak <[email protected]>
Co-authored-by: Jinwoo-H <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OMP task subagent transcripts are flattened into top-level Agent Session History

4 participants