ISSUE DESCRIPTION Deep-research / workflow subagent transcripts aren't discovered…
- User
ISSUE DESCRIPTION
Deep-research / workflow subagent transcripts aren't discovered (nested under subagents/workflows/)
What I was doing
Running Claude Code's
/deep-researcha few times, then looking for those sessions in agentsview. Each run fans out into ~100 subagents and leaves a large pile of per-agent transcripts on disk — exactly the kind of session history I'd want to browse and analyze in agentsview after the fact.What happened
None of the deep-research subagent transcripts show up in agentsview. The parent session imports fine; the ~100 subagents per run are invisible.
The cause is a path-depth assumption in discovery.
DiscoverClaudeSessionslooks for subagent transcripts exactly one level down:<project>/<session>/subagents/agent-<id>.jsonland in that loop it skips any directory entry:
// internal/parser/discovery.go ~L359 for _, sub := range subFiles { if sub.IsDir() { continue // ← never descends } name := sub.Name() if !strings.HasPrefix(name, "agent-") || !strings.HasSuffix(name, ".jsonl") { continue } ... }But deep-research (and Workflow-tool runs generally) write their subagent transcripts one level deeper, grouped by workflow id:
<project>/<session>/subagents/workflows/<wf_id>/agent-<id>.jsonlsubagents/here contains only theworkflows/directory, which the loop skips — so the entire tree underneath is never discovered. Each transcript carriesisSidechain: trueand an accompanyingagent-<id>.meta.jsonwhoseagentTypeisworkflow-subagent.Concretely, in one session three
/deep-researchruns produced 312agent-*.jsonlfiles undersubagents/workflows/, and zero directly undersubagents/. All 312 are currently dropped.Why it matters
Deep research is one of the highest-value things to capture: a single invocation can spawn a hundred subagents and burn a lot of tokens, and right now that whole tree is invisible in agentsview — no transcripts, no token/usage attribution, no way to review what the subagents actually did. As more people lean on workflow-style fan-out, this is a growing blind spot.
The fix looks small: walk
subagents/recursively (or specifically also descend intosubagents/workflows/<wf_id>/) instead of only reading its top level, and treatagent-*.jsonlfound anywhere beneath it the same way. The () is available alongside each transcript if the workflow grouping is worth surfacing in the UI. Assistant
Let me explore the repository structure and the relevant file mentioned in the issue.
Assistant
Now I understand the issue. The loop at the top level of
subagents/skips directories, so it never descends intosubagents/workflows/<wf_id>/. Let me fix this by walking thesubagents/directory recursively.Assistant
Let me see the full FindClaudeSourceFile function to understand the second part too.
Assistant
Let me look at the existing tests for discovery.
Assistant
Now let me look at the FindClaudeSourceFile test to understand the structure for the second function I need to modify.
Assistant
Now I understand both functions. Let me modify the discovery to walk
subagents/recursively. First, theDiscoverClaudeProjectsfunction:Assistant
Now let me replace the subagent scanning loop with a recursive walk:
Assistant
Now let me check the imports to make sure
filepath.WalkDiris available (filepath is likely already imported):Assistant
Good, both
osandpath/filepathare imported. Now let me fix the second function,FindClaudeSourceFile, which also only looks at the top level ofsubagents/. Let me look at it again:Assistant
Let me see the full FindClaudeSourceFile function:
Assistant
Now let me update the
FindClaudeSourceFilesubagent section to also search recursively within thesubagents/directory:Assistant
The line range needs a colon. Let me fix:
Assistant
There are leftover closing braces from the original code at lines 515-517. Let me remove them:
Assistant
Now let me build to verify the code compiles:
Assistant
There's a syntax error near the end of FindClaudeSourceFile. Let me check:
Assistant
I removed one too many closing braces. The
if strings.HasPrefix(...)block isn't closed. Let me check the exact current state:Assistant
I need to add the closing brace for the
if strings.HasPrefixblock. Let me look at the line numbers:Assistant
Line 513 (
}) closes the for-entry loop. I need to add a}to close theifblock. Let me edit:Assistant
Now let me build:
Assistant
Build succeeds. Now let me run the existing discovery tests:
Assistant
All existing tests pass. Now let me write a temporary reproduction script to confirm the fix works for the workflow-nested transcripts:
Assistant
Both new tests pass. Let me verify the temp test file is removed and run the full parser test suite to make sure nothing broke:
Assistant
The temp test file is removed. Only
discovery.gois modified. Let me run the full parser test suite:Assistant
Let me check if that failure is pre-existing (unrelated to my change) by stashing my changes:
Assistant
The
TestParseCortexSession_SplitHistoryReadErrorfailure is pre-existing (fails on a clean checkout too, unrelated to my change — it's an environment issue with file permissions running as root). Let me run all the discovery tests plus the broader Claude parser/subagent tests to confirm my change is clean:Assistant
All discovery and Claude-related tests pass. Let me review the final diff:
Assistant
The diff looks clean. Let me check whether there's any path-depth-dependent logic elsewhere that derives the session ID or project from the discovered file path (which might break for the deeper nested paths):
Assistant
Let me check how the project/session relationship is derived from the discovered path — specifically
types.go:760and theproject.go:Assistant
Let me check the project.go to see how project/session is derived from path, and check whether there's a
project.gofunction that determines the parent session from a path.Assistant
That's about git repo root. Let me check how the Claude parser determines the parent session for a subagent — whether it's path-based or content-based:
Assistant
Let me check how the discovered files are consumed — how project and session are derived:
Assistant
Let me check how the session ID is derived from the discovered file path:
Assistant
Let me check the ingest path to confirm session ID comes from content and project from the DiscoveredFile:
Assistant
There's a
classifyOnePathfunction in the sync engine that handles the file-watcher path classification — it has the same path-depth assumption (len(parts) == 4 && parts[2] == "subagents"). This is used for incremental sync on file changes, so workflow-nested transcripts wouldn't be picked up by the watcher either. Let me examine it:Assistant
I found the second place with the same path-depth assumption — in the sync engine's
classifyOnePath(used for the file watcher / incremental sync). It only matcheslen(parts) == 4 && parts[2] == "subagents". I need to generalize it to handle the nested workflow paths too. Let me check for existing tests first:Assistant
Now let me modify the
classifyOnePathClaude subagent handling to also match nested workflow paths:Assistant
Now let me update the
classifyOnePathsubagent handling to match nested paths:Assistant
Let me update the comment at the top of the Claude section too:
Assistant
Now let me build and run the sync engine tests:
Assistant
Build passes. Now let me write a temporary test to verify the sync engine
classifyOnePathhandles nested workflow paths:Assistant
I need to add the
osimport. Let me fix the temp test:Assistant
Both the flat and nested workflow paths now classify correctly in the sync engine. Let me run the broader existing sync engine tests to make sure nothing broke:
Assistant
Let me run the full sync engine test suite to ensure nothing is broken:
Assistant
All sync tests pass. Let me also check whether there's anywhere else that parses paths to find the parent session from a subagent file (e.g., a function that derives the parent session directory from a subagent path). Let me search broadly for
subagentspath assumptions across the codebase:Assistant
There's another spot at
engine.go:5592. Let me check it:Assistant
This
len(parts) == 4check is forparser.AgentWorkBuddy(a separate agent type), not Claude. The issue is specifically about Claude deep-research. Let me check if there's a Claude case in this switch that derives the project from the path:Assistant
Let me understand the context of this function — what function is this, and how does it relate to
classifyOnePath:Assistant
This
syncSinglefallback derives the project viafilepath.Base(filepath.Dir(path)), which gives wrong results for nested paths (the workflow ID). Let me check how the Claude parser derives the project — from path or from content:Assistant
Let me look at the full Claude case in
syncSingleto improve the project derivation for nested paths:Assistant
Let me improve the Claude project derivation fallback so it correctly handles nested subagent paths. Let me check if there's an existing helper for deriving the Claude project from a path:
Assistant
I'll add a helper to derive the Claude project from the path robustly, then use it in the
syncSinglefallback. Let me first add the helper nearclassifyOnePath:Assistant
Let me add a helper method. First, let me find where
classifyOnePathends:Assistant
classifyOnePathends at line 1082. Let me view the lines right after it to insert the helper:Assistant
I need to add a blank line between the new function and the next. Let me fix that:
Assistant
Now let me update the
syncSingleClaude case to use the new helper:Assistant
Now let me build and run the tests:
Assistant
Now let me write a comprehensive end-to-end test that simulates the exact scenario from the issue (deep-research with workflow-nested subagents) to verify discovery, classification, and FindSourceFile all work:
Assistant
Let me check the SyncAll signature:
Assistant
The discovery, classification, project derivation, and sync all work. The only failing assertion is
ParentSessionID— that's content-based parent-linking, which depends on the parent session having the right tool-call/result structure. My minimal test data doesn't set that up. Let me verify this is a test-data issue (not a regression) by checking how the existing flat-subagent integration test sets up linkage:Assistant
The parent-linking is content-based and uses specific helpers. Let me look at the test helpers to set up linkage properly in my e2e test:
Assistant
Rather than reconstruct the whole test infrastructure, let me just use the existing helpers. Let me write the e2e test using
setupTestEnv,writeClaudeSession,writeSession, and thetestjsonl.NewSessionBuilder(). Let me look at these helpers and theAddClaudeUserWithSessionIDsignature.Assistant
Now I have enough to rewrite the e2e test using the existing helpers. Let me check the
testjsonlpackage andrunSyncAndAssert,assertSessionStatehelpers.Assistant
Let me view the existing flat-subagent integration test fully to mirror it with nested paths:
Assistant
Now I understand the linkage. Let me rewrite the e2e test mirroring the existing
TestSyncSubagentSetsParentSessionIDbut with nested workflow paths. Let me check the timestamp constants used:Assistant
The integration tests use
package sync_test(external test package). My temp test usedpackage sync(internal) to accessclassifyOnePathandclaudeProjectFromPath(unexported). Let me keep my test inpackage sync(internal) and use the helpers that are accessible. TheassertSessionState,runSyncAndAssertare intest_helpers_test.gowhich ispackage sync(internal helpers, no_testsuffix in package name? Let me check).Actually
test_helpers_test.go— the filename ends with_test.goso it's a test file. Let me check its package declaration.Assistant
test_helpers_test.goispackage sync_test(external). My test usespackage sync(internal). Let me check whatopenTestDBis (used in my earlier test):Assistant
Now I have everything. Let me rewrite the e2e test using the proper helpers with linkage:
Assistant
Let me just use
os.MkdirAllandos.WriteFiledirectly:Assistant
I imported
dbbut don't use it directly (I usegot.Projectetc. via the returned*db.Sessionwhich is inferred). Let me remove the unused import. ActuallyopenTestDBreturns*db.DBanddb_.GetSessionreturns*db.Sessionbut I don't reference thedbpackage name directly. Let me remove the import.Assistant
Excellent! Almost everything passes — discovery (4 files), FindSourceFile, classifyOnePath, claudeProjectFromPath, sync (4 synced), project attribution, AND parent linkage (ParentSessionID) all pass! The only failure is a type mismatch:
Session.Agentis astring, notparser.AgentType. Let me fix that comparison:Assistant
The end-to-end test fully passes: the deep-research workflow-nested subagents are discovered, located by ID, classified by the watcher, project-attributed, synced, and linked to the parent session. Now let me clean up the temp test and run the full test suites for both affected packages:
Assistant
Only the two source files are modified. Let me run the full test suites for both packages to ensure nothing is broken:
Assistant
The only failing test is
TestParseCortexSession_SplitHistoryReadError, which I already confirmed is pre-existing (fails on a clean checkout too — it's an environment issue with file permissions when running as root, since root can read files even with0o000permissions). Theinternal/syncpackage passes fully. Let me confirm everything else in the parser package passes by excluding that pre-existing failure:Assistant
All other parser tests pass. Let me also run the broader build and vet across the whole repo to ensure nothing else is affected:
Assistant
Let me review the final complete diff to ensure everything is correct:
Assistant
The diff is clean and complete. Let me do a final verification — run the discovery and sync tests once more and confirm no temp files remain:
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.