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 start by exploring the repository structure to understand the codebase and locate the relevant files mentioned in the issue.
The issue mentions:
internal/parser/discovery.go- contains theDiscoverClaudeSessionsfunction- The problem is that it only looks for subagent transcripts one level down (
<project>/<session>/subagents/agent-<id>.jsonl) - But deep-research writes them one level deeper (
<project>/<session>/subagents/workflows/<wf_id>/agent-<id>.jsonl)
Let me explore the repository structure first.
Assistant
Let me look at the internal/parser directory and find the discovery.go file mentioned in the issue.
<tool_call> <function=bash_terminal> <parameter=command> find . -name "discovery.go" -type f </tool_call>
Assistant
I need to run the find command properly - it seems the command got lost. Let me try again with the bash_terminal tool.
Assistant
Now let me look at the discovery.go file to understand the current implementation.
<tool_call> <function=bash_terminal> <parameter=command> cat ./internal/parser/discovery.go </tool_call>
Assistant
Let me run the bash command properly to view the discovery.go file.
Assistant
The file is truncated in the output. Let me look specifically at the
DiscoverClaudeSessionsfunction mentioned in the issue around line 359.Let me view the file around line 359 to find the code that handles subagent discovery.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '340,420p' ./internal/parser/discovery.go </tool_call>
Assistant
I need to run a bash command to view the discovery.go file around line 359 where the subagent discovery logic is. Let me use sed to extract the relevant lines.
Assistant
I can now see the relevant code around lines 349-382. The issue is that when it encounters a directory in
subagents/(likeworkflows/), it just skips it withcontinue. This means it never descends into subdirectories likesubagents/workflows/<wf_id>/.Let me see more of the
DiscoverClaudeSessionsfunction to understand its full structure.<tool_call> <function=bash_terminal> <parameter=command> sed -n '300,395p' ./internal/parser/discovery.go </tool_call>
Assistant
Let me view more of the DiscoverClaudeSessions function to understand its structure better.
Assistant
Now I can see the
DiscoverClaudeSessionsfunction (lines 308-383). The issue is at lines 361-363:for _, sub := range subFiles { if sub.IsDir() { continue // ← this skips subdirectories like "workflows/" } ... }The fix should:
- When encountering a subdirectory under
subagents/(likeworkflows/), descend into it recursively - Look for
agent-*.jsonlfiles anywhere beneathsubagents/
Let me also check if there are any existing tests for this function to understand the expected behavior better.
<tool_call> <function=bash_terminal> <parameter=command> grep -r "DiscoverClaudeSessions|DiscoverClaudeProjects" --include="*.go" ./ </tool_call>
- When encountering a subdirectory under
Assistant
Let me search for tests and references to the DiscoverClaudeSessions function.
Assistant
Let me look at the test file to understand the expected structure better.
Assistant
Now I have a clear picture. The current test case for "Subagents" only tests the flat case where
agent-*.jsonlfiles are directly undersubagents/. I need to:- Modify the
DiscoverClaudeProjectsfunction to walk recursively undersubagents/directories - Make sure the tests cover the new case
Let me also check if there's a
FindClaudeSourceFilefunction that might need updating:<tool_call> <function=bash_terminal> <parameter=command> sed -n '420,550p' ./internal/parser/discovery.go </tool_call>
- Modify the
Assistant
Let me use bash_terminal to find the FindClaudeSourceFile function.
Assistant
Now I can see the
FindClaudeSourceFilefunction (lines 435-486). The function already searches for subagent files undersubagents/at line 473-479, but it only looks one level down:candidate := filepath.Join( projDir, sd.Name(), "subagents", target, )This also needs to be updated to search recursively under
subagents/.Now I have a clear plan:
- Modify
DiscoverClaudeProjectsfunction to walk recursively undersubagents/directories - Modify
FindClaudeSourceFilefunction to search recursively undersubagents/directories
Let me write the fix. I'll need to change:
- In
DiscoverClaudeProjects(around line 361-379): Instead of skipping directories undersubagents/, walk into them recursively. - In
FindClaudeSourceFile(around line 469-480): Instead of only looking atsubagents/target, walk recursively.
Let me look at the exact code structure first to understand the indentation and formatting.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '360,383p' ./internal/parser/discovery.go </tool_call>
- Modify
Assistant
The sed command didn't seem to work as expected. Let me try a different approach to view the specific lines of the discovery.go file.
Assistant
Now I can see the code. The subagent scanning code starts at line 361. I need to modify it to recursively walk into subdirectories like
workflows/undersubagents/. Let me also check line numbers forFindClaudeSourceFile.Assistant
Now I understand the structure. Let me write the fix. I need to modify the
DiscoverClaudeProjectsfunction to walk recursively undersubagents/directories, and also updateFindClaudeSourceFileto search recursively.Assistant
Now I have a clear understanding. The code at lines 361-380 needs to be modified to walk recursively under subagents/ directories. Let me make the fix using the edit command.
Assistant
Let me use the sed command to view the exact lines that need to be modified.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '361,378p' ./internal/parser/discovery.go </tool_call>
Assistant
The sed command didn't show output. Let me try a different approach - viewing the file in parts.
Assistant
Now I can see the exact lines. Lines 359-375 need to be modified to walk recursively into subdirectories. The key change is:
- Lines 359-362: Instead of
continuewhensub.IsDir(), we should usefilepath.WalkDirto recursively walk into the directory. - Lines 368-374: We need to compute the full path properly for files found recursively.
Let me write the replacement. The new code should:
- When encountering a directory under
subagents/, walk into it recursively - Look for
agent-*.jsonlfiles at any depth - Build the full path correctly
<tool_call> <function=bash_terminal> <parameter=command> cat ./internal/parser/discovery.go | head -n 1 | grep "package" </tool_call>
- Lines 359-362: Instead of
Assistant
Let me just use the edit command to replace the code block. I need to understand the exact indentation used in this file first.
Assistant
Now I can see the exact indentation - 16 spaces for the outer block and 18 spaces for the inner block. I need to replace lines 359-375 with code that walks recursively. Let me create the replacement:
Assistant
Now let me use the bash_terminal to run the edit command. I need to use the edit command to replace the code.
<tool_call> <function=bash_terminal> <parameter=command> edit --file ./internal/parser/discovery.go 359:375 << 'EOF' for _, sub := range subFiles { if sub.IsDir() { // Recursively walk into subdirectories like // subagents/workflows/<wf_id>/ subPath := filepath.Join(subagentsDir, sub.Name()) filepath.WalkDir(subPath, func(walkPath string, d os.DirEntry, err error) error { if err != nil { return nil } if d.IsDir() { return nil } name := d.Name() if !strings.HasPrefix(name, "agent-") || !strings.HasSuffix(name, ".jsonl") { return nil } files = append(files, DiscoveredFile{ Path: walkPath, Project: entry.Name(), Agent: AgentClaude, }) return nil }) continue } name := sub.Name() if !strings.HasPrefix(name, "agent-") || !strings.HasSuffix(name, ".jsonl") { continue } files = append(files, DiscoveredFile{ Path: filepath.Join( subagentsDir, name, ), Project: entry.Name(), Agent: AgentClaude, }) } EOF </tool_call>
Assistant
Let me try using the edit special command correctly:
Assistant
Let me try using sed to make the changes directly:
Assistant
Let me use Python to make the multi-line replacement:
Assistant
Now let me verify the change in
DiscoverClaudeProjectsand then updateFindClaudeSourceFileas well.Assistant
Now let me find the
FindClaudeSourceFilefunction and update it to search recursively under subagents/:Assistant
Let me see more of the FindClaudeSourceFile function:
Assistant
Now I need to update the
FindClaudeSourceFilefunction to also search recursively undersubagents/. The current code at lines 486-495 only looks one level down atsubagents/target. I need to change it to walk recursively.Let me first see the full function to understand where it ends:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '480,510p' ./internal/parser/discovery.go </tool_call>
Assistant
Let me try to view lines 480-510 in a different way to understand the full FindClaudeSourceFile function.
Assistant
Now I understand the structure. The
FindClaudeSourceFilefunction ends around line 512. The subagent search part is lines 482-509. I need to modify this to walk recursively undersubagents/directories.The current code at lines 497-505:
candidate := filepath.Join( projDir, sd.Name(), "subagents", target, ) if _, err := os.Stat(candidate); err == nil { return candidate }Assistant
Let me use a simpler and cleaner approach for
FindClaudeSourceFile:Assistant
Now let me verify the changes in
FindClaudeSourceFile:Assistant
Let me see the rest of the function to verify the complete change:
Assistant
Now let me verify the code compiles correctly by running the Go compiler:
Assistant
I need to set up the Go module cache first:
Assistant
Let me set the required environment variables:
Assistant
I need to fix the error -
filepath.ErrCloseddoesn't exist. I need to use a different approach to break out of the WalkDir loop. Let me fix this by using a custom error variable instead.Let me first view the current state of the code to see what I need to fix: <tool_call> <function=bash_terminal> <parameter=command> sed -n '497,525p' ./internal/parser/discovery.go </tool_call>
Assistant
Let me view the current state of the FindClaudeSourceFile function to fix the ErrClosed issue.
Assistant
The issue is that
filepath.ErrCloseddoesn't exist. I need to define a custom error or use a different approach. Let me usefmt.Errorfto create a custom error.<tool_call> <function=bash_terminal> <parameter=command> python3 << 'EOF' with open('./internal/parser/discovery.go', 'r') as f: content = f.read()
Replace filepath.ErrClosed with fmt.Errorf("done")
old_code = ''' foundPath := "" filepath.WalkDir(subagentsDir, func(walkPath string, d os.DirEntry, err error) error { if foundPath != "" { return filepath.ErrClosed } if err != nil { return nil } if d.IsDir() { return nil } name := d.Name() if name == target { foundPath = walkPath return filepath.ErrClosed } return nil })'''
new_code = ''' foundPath := "" filepath.WalkDir(subagentsDir, func(walkPath string, d os.DirEntry, err error) error { if foundPath != "" { return fmt.Errorf("done") } if err != nil { return nil } if d.IsDir() { return nil } name := d.Name() if name == target { foundPath = walkPath return fmt.Errorf("done") } return nil })'''
if old_code in content: content = content.replace(old_code, new_code) with open('./internal/parser/discovery.go', 'w') as f: f.write(content) print("Replacement successful!") else: print("Old code not found!") EOF </tool_call>
Assistant
The command didn't seem to execute. Let me try using a different approach - using bash to write the file directly.
Assistant
Now let me verify the change and try to build again:
Assistant
Now let me check the DiscoverClaudeProjects code that also uses filepath.WalkDir - I need to verify it doesn't use filepath.ErrClosed:
Assistant
Now let me try to build the code again:
Assistant
The code compiles successfully. Now let me run the existing tests to make sure the changes don't break anything:
<tool_call> <function=bash_terminal> <parameter=command> export GOMODCACHE=/tmp/go-mod-cache && export GOCACHE=/tmp/go-cache && go test ./internal/parser/ -v -run TestDiscoverClaudeProjects </tool_call>
Assistant
Let me run the test command properly.
Assistant
The existing tests pass! Now let me add a test case to cover the new functionality - subagents nested under workflows/. Let me also run all the parser tests to make sure nothing is broken:
<tool_call> <function=bash_terminal> <parameter=command> export GOMODCACHE=/tmp/go-mod-cache && export GOCACHE=/tmp/go-cache && go test ./internal/parser/ -v 2>&1 | tail -50 </tool_call>
Assistant
Let me run all the tests in the parser package.
Assistant
The test results show that my changes work correctly - the
TestDiscoverClaudeProjectsandTestFindClaudeSourceFiletests all pass. There's one pre-existing test failure (TestParseCortexSession_SplitHistoryReadError) that is unrelated to my changes.Now let me create a quick test script to verify that my fix works for the specific issue described - finding subagent transcripts nested under
subagents/workflows/<wf_id>/:Assistant
Assistant
Let me run it as a test instead:
Assistant
The fix works. Let me clean up the test file and verify my changes with git diff:
<tool_call> <function=bash_terminal> <parameter=command> rm ./internal/parser/test_workflows_main.go ./internal/parser/test_workflows_manual.go ./internal/parser/discovery.go.backup 2>/dev/null; git diff ./internal/parser/discovery.go </tool_call>
Assistant
The rm command seems to have not executed properly. Let me run the git diff command to see my changes.
Assistant
The diff shows my changes correctly implement the fix. Let me verify there are no leftover files and run the tests one more time:
Assistant
The test_helpers_test.go is the original test file, not my temporary files. Good. Now let me verify the git status to ensure everything is clean:
Assistant
Let me run the relevant tests one more time to ensure everything works correctly:
Assistant
All tests pass. Let me submit the solution:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.