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:code<project>/<session>/subagents/agent-<id>.jsonland in that loop it skips any directory entry:
go// 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:
code<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.
Assistant
Let me start by exploring the repository structure and understanding the codebase.
Assistant
Now let me look at the second occurrence around line 461-480.
Assistant
Let me see the full function that contains the first occurrence.
Assistant
Let me look at existing tests for these discovery functions.
Assistant
Let me look at the claude_subagent files and understand how subagent files are processed.
Assistant
Now let me write a reproduction test to confirm the issue.
Assistant
The issue is confirmed. Now let me fix the discovery code to recursively walk the
subagents/directory.Assistant
Now let me fix
FindClaudeSourceFileto also search recursively. Let me view it.Assistant
Let me check the Go version to make sure
filepath.SkipAllis supported.Assistant
filepath.SkipAllis supported. Now let me re-add the repro test to confirm the fix.Assistant
Both fixes work. Now let me run the existing parser tests to make sure nothing is broken.
Assistant
Let me check whether this failure pre-exists (unrelated to my change) by stashing.
Assistant
The cortex failure is pre-existing and unrelated (running as root breaks permission-based test). Let me run the discovery-specific tests.
Assistant
All discovery tests pass. Let me build the whole repo and run the cmd tests that touch discovery.
Assistant
Let me check for other places that assume the one-level subagents path.
Assistant
There's the sync engine with path-part assumptions. Let me look at those.
Assistant
The sync engine's
classifyPath(or similar function) also has the path-part assumption. For workflow subagents, the path would be:<claudeDir>/<project>/<session>/subagents/workflows/<wf_id>/agent-<id>.jsonlThat's
len(parts) == 6withparts[2] == "subagents"andparts[3] == "workflows". The current checklen(parts) == 4 && parts[2] == "subagents"would miss these.Let me look at the broader function and the line 5590 area too, and line 705-730 (workbuddy). The workbuddy is a different agent, leave it. Let me focus on the Claude subagent classification.
Let me look at line 5590.
Assistant
The line 5590 is in a project-determination function for WorkBuddy. Let me look at the broader context of that function to understand which agent it applies to. It's a
case parser.AgentWorkBuddy:so it's only for WorkBuddy, leave it.Now let me focus on the Claude subagent classification in the
classifyPathfunction (around lines 461-510). The issue is specifically about discovery, but the sync engine also needs to handle these workflow subagents for incremental file-watching sync. If a user runs/deep-researchafter agentsview is already watching, the new workflow subagent files would be classified byclassifyPath. Without the fix, they'd be missed (or misclassified).Let me understand the function name and structure. Let me look at the beginning of this classify function.
Assistant
The function is
classifyOnePath. Let me understand how it's used. Let me check the callers and whether this is part of file watching. Let me also check howclassifyPath(the public wrapper) calls this.Assistant
classifyOnePathis used bySyncPaths, which handles incremental file-watching changes. So workflow subagent transcripts written during a/deep-researchrun would be classified here too. I need to fix this classification as well. Let me view the exact block.Assistant
Now let me update the Claude subagent classification in the sync engine to handle the deeper workflow paths.
Assistant
Now let me check parser types.go around line 760 and other path-based subagent detection logic.
Assistant
Let me search for path-based parent session derivation logic in the parser package.
Assistant
Let me check the Claude subagent parsing to see how it derives the parent session and whether path depth matters.
Assistant
The Claude parser derives parentSessionID from session content, not path. Let me check how the sync engine determines a subagent's parent session ID and whether path depth matters there.
Assistant
Let me look at how the Claude parser derives the parent session for a subagent file.
Assistant
The parent session ID is derived from the JSONL content (
sessionIdfield), not the path, so it works regardless of depth. Let me build and run the sync engine tests.Assistant
Let me check the sync tests for subagent path classification to verify existing behavior is intact and add a quick repro for the engine.
Assistant
Let me look at a classify test to understand the minimal harness for
classifyOnePath.Assistant
Let me write a temporary repro test for
classifyOnePathwith a Claude workflow subagent path.Assistant
Both fixes work. Let me clean up the repro test files.
Assistant
Now let me run the broader test suite to confirm everything is intact.
Assistant
The only failure is
TestParseCortexSession_SplitHistoryReadError, which I already confirmed is pre-existing and unrelated to my change. Let me verify this by examining the test.Assistant
Confirmed: the cortex test relies on
chmod 0o000to make a file unreadable, but tests run asroot, which bypasses permissions. This is a pre-existing, environment-specific failure unrelated to my change.Let me review my final diff.
Assistant
Let me check for any other places in the codebase with the old path-depth assumption that I might have missed.
Assistant
The remaining two occurrences are for
AgentWorkBuddy, a distinct agent with its own discovery conventions (internal/parser/workbuddy.go) — out of scope for this Claude deep-research issue. I'll leave those alone.Let me run
go vetand the affected test packages once more to confirm everything is clean.Assistant
Everything passes and
go vetis clean. Let me confirm no leftover test files remain and do a final status check.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.