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
I'll start by exploring the repository structure and understanding the relevant code.
Assistant
I found the relevant code. Let me look at the exact subagent discovery section more closely.
Assistant
Let me see the rest of the file and understand the helper patterns used.
Assistant
Let me look at the testdata and existing tests for these functions.
Assistant
Let me check for any watch mechanism related to Claude subagents that might also need updating.
Assistant
Let me examine the sync engine logic for subagents.
Assistant
So the engine has path classification logic at line 487-498 for subagents (len(parts) == 4). For workflows, the path would be
<project>/<session>/subagents/workflows/<wf_id>/agent-<id>.jsonl, which is 6 parts with parts[2] == "subagents" and parts[3] == "workflows".Let me look at line 5590 too.
Assistant
Let me check how Claude watch roots are resolved and whether there's a function for resolving watch directories.
Assistant
Let me understand the broader sync/watch architecture. Let me check how watch roots are determined for the engine and whether a recursive watcher is used. Let me look at how the watcher is set up in the engine.
Assistant
Let me find where the watcher is set up for Claude dirs in the engine.
Assistant
Let me check the Claude agent definition's
ShallowWatchandWatchSubdirs.Assistant
The watcher uses recursive watch for Claude, so newly created nested dirs would be watched. But the classify logic only handles
len(parts) == 4. Let me look at the broader classify function.Assistant
Now I understand the full picture. Let me check the watcher's exclude logic to ensure
workflowsisn't excluded.Assistant
Now I have a full understanding. Let me make the fixes. First, let me reproduce the issue by creating a test scenario.
Assistant
The Go module cache is not set up. Let me check the Go environment.
Assistant
The module cache exists at
/root/go/pkg/mod. Let me set the env vars.Assistant
Now let me run the reproduction test to confirm the issue.
Assistant
Confirmed the bug. The nested workflow subagents aren't discovered. Now let me fix the code. First, let me open the discovery.go file.
Assistant
Now let me fix the
DiscoverClaudeProjectsfunction to walk thesubagents/directory recursively:Assistant
Now let me fix
FindClaudeSourceFileto walk thesubagents/tree recursively:Assistant
Now I need to add the
findFileInDirhelper function. Let me add it afterFindClaudeSourceFile:Assistant
Now let me fix the
classifyOnePathfunction inengine.goto handle the nested workflow paths:Assistant
Now let me check the project resolution code path for Claude agent files (around line 5560) to ensure nested paths get proper project attribution.
Assistant
Let me trace the full flow of the single-path sync function to understand project resolution.
Assistant
Let me check how the Claude parser extracts the project from file content and whether there's a project reparse step.
Assistant
Let me look at how
processFileresolves the project for Claude sessions.Assistant
Let me look at
processClaudeto see how the project gets resolved.Assistant
Let me look at the subagent test data to understand the transcript format and whether cwd is present.
Assistant
Subagent transcripts contain
cwd, soprocessClaudere-resolves the project from cwd. Let me verify the watcher path actually usesclassifyOnePath.Assistant
The watcher uses
SyncPaths→classifyOnePath, which I've fixed. Now let me build and run the reproduction test.Assistant
The reproduction test passes. Now let me also write a test for the
classifyOnePath(engine) to confirm the watcher path handles nested workflow paths. Let me check existing classify tests in the sync package.Assistant
Let me write a temporary test in the sync package to confirm
classifyOnePathhandles nested workflow subagent paths.Assistant
Both nested and flat subagents classify correctly. Now let me remove the temporary test files and run the existing test suites.
Assistant
Existing discovery tests pass. Now let me run the broader parser and sync test suites to make sure nothing is broken.
Assistant
There's a failure in
TestParseCortexSession_SplitHistoryReadError. Let me check if it's pre-existing by stashing my changes.Assistant
The
TestParseCortexSession_SplitHistoryReadErrorfailure is pre-existing (fails on original code too, likely because tests run as root). It's unrelated to my changes. Let me confirm the sync suite passed and check the parser suite for any failures related to my changes.Assistant
Only the pre-existing cortex test fails (unrelated, root permissions). Let me check the existing symlink test for
FindClaudeSourceFileto ensure my changes handle symlinks.Assistant
The symlink test (top-level session) is unaffected by my changes. Let me review the final diff and run the sync classify tests.
Assistant
The diff looks clean. Let me run the full sync test suite once more to confirm nothing broke, plus the relevant classify tests.
Assistant
All sync tests pass, including
TestSyncPathsClaudeRejectsNested. Let me examine that test to make sure my change aligns with its intent.Assistant
TestSyncPathsClaudeRejectsNestedwritesproj/subdir/nested.jsonl(parts[2] is "nested.jsonl", not "subagents"), so it's still correctly rejected — no conflict with my fix.Let me check the default watch exclude patterns to ensure
workflowsdirs aren't excluded from watching.Assistant
The default watch excludes (
.git,node_modules, etc.) don't matchworkflows, so nested dirs are watched correctly. Let me rungo vetand a final build across the repo.Assistant
Let me run one final comprehensive test mirroring the exact issue scenario (many files under
subagents/workflows/, none directly undersubagents/), then remove it.Assistant
The test bug — I forgot to create the
myprojdir. Note the actual count is 312 workflow subagents discovered (correct!). Let me fix the test.Assistant
The full issue scenario now works: all 312 workflow subagents discovered, meta files ignored,
FindClaudeSourceFilelocates nested files. Let me clean up the temporary test.Assistant
Only the two source files are modified. Let me do a final test run of both packages to confirm only the pre-existing cortex failure remains.
Assistant
Only the pre-existing
TestParseCortexSession_SplitHistoryReadErrorfailure remains — it fails identically on the unmodified original code (root permission semantics) and is unrelated to my change. The sync package passes entirely.Let me do a final review of the complete diff before submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.