Deep-research / workflow subagent transcripts aren't discovered (nested under subagents/workflows/)
What I was doing
Running Claude Code's /deep-research a 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. DiscoverClaudeSessions looks for subagent transcripts exactly one level down:
code
<project>/<session>/subagents/agent-<id>.jsonl
and 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:
subagents/ here contains only the workflows/ directory, which the loop skips — so the entire tree underneath is never discovered. Each transcript carries isSidechain: true and an accompanying agent-<id>.meta.json whose agentType is workflow-subagent.
Concretely, in one session three /deep-research runs produced 312agent-*.jsonl files under subagents/workflows/, and zero directly under subagents/. 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
The issue is about deep-research/subagent transcripts not being discovered by the agentsview tool. The problem is in the DiscoverClaudeSessions function in internal/parser/discovery.go - it only looks at the top level of the subagents/ directory and skips subdirectories, but deep-research creates subagent transcripts in subagents/workflows/<wf_id>/agent-<id>.jsonl (two levels deep).
Let me start by exploring the repository structure and understanding the codebase.
Assistant
Let me look at the discovery.go file mentioned in the issue.
Assistant
The file is truncated. Let me look specifically for the DiscoverClaudeSessions function and the subagent handling code around line 359.
Assistant
Let me look at the relevant lines around 350-400 to see the subagent discovery code.
Assistant
Now let me see the full DiscoverClaudeSessions function to understand its structure better:
<tool_call>
<function=bash_terminal>
<parameter=command>
sed -n '320,380p' /agentsview/internal/parser/discovery.go
</tool_call>
Assistant
Let me search for the DiscoverClaudeSessions function properly.
Assistant
So the function is DiscoverClaudeProjects, not DiscoverClaudeSessions. Let me look at the full function to understand its structure and how to fix the subagent discovery issue.
Assistant
Now I can see the issue. The subagent discovery code at lines 352-376 only looks at the top level of the subagents/ directory. It skips directories (line 365-366: if sub.IsDir() { continue }), which means it won't find files nested under subagents/workflows/<wf_id>/agent-*.jsonl.
The fix is to recursively walk the subagents/ directory to find all agent-*.jsonl files at any depth. Let me check if there's a similar pattern elsewhere in the file for recursive walking.
Let me check for filepath.Walk usage in the codebase.
Assistant
Let me check how filepath.Walk is used in that file.
<tool_call>
<function=bash_terminal>
<parameter=command>
sed -n '85,130p' /agentsview/internal/sync/watcher.go
</tool_call>
Assistant
Let me continue looking at the watcher.go file to see how filepath.WalkDir is used.
Assistant
Now I have a good understanding of how filepath.WalkDir is used. Let me now understand the test data to see what the structure looks like for deep-research subagents.
Let me explore the testdata directory to understand the structure of subagent files.
Assistant
The testdata directory doesn't seem to have extensive test data. Let me look at the existing test files to understand how they test discovery.
Assistant
Let me search for parser tests.
Assistant
Let me look at the discovery_test.go to understand how the discovery tests work.
<tool_call>
<function=bash_terminal>
<parameter=command>
cat /agentsview/internal/parser/discovery_test.go
</tool_call>
Assistant
The output was too long or had an issue. Let me try a different approach to see the file.
Assistant
The file has 1341 lines. Let me look at the beginning to understand its structure and find tests related to Claude subagents.
<tool_call>
<function=bash_terminal>
<parameter=command>
sed -n '1,100p' /agentsview/internal/parser/discovery_test.go
</tool_call>
Assistant
The output seems to be getting truncated. Let me try to run the discovery_test.go directly using bash.
Assistant
Let me look at a specific test case for Claude subagents.
Assistant
Now I have a good understanding of the code structure. Let me now create a fix for the subagent discovery issue. The fix needs to:
Walk the subagents/ directory recursively instead of just reading its top level
Find all agent-*.jsonl files at any depth under subagents/
Let me look at the exact code block that needs to be changed again:
<tool_call>
<function=bash_terminal>
<parameter=command>
sed -n '345,380p' /agentsview/internal/parser/discovery.go
</tool_call>
Assistant
Let me use bash terminal to output the relevant section of the discovery.go file.
Assistant
Now I can see the code that needs to be changed. The issue is:
Line 355-356: Uses os.ReadDir(subagentsDir) which only reads the top level
Line 360-361: Skips directories with if sub.IsDir() { continue }
The fix should replace this with a recursive walk using filepath.WalkDir. Let me create the fix:
<tool_call>
<function=bash_terminal>
<parameter=command>
sed -n '345,380p' /agentsview/internal/parser/discovery.go
</tool_call>
Assistant
The sed output is not being captured. Let me try a different approach.
Assistant
Assistant
Let me run the python script using the bash_terminal function.
Assistant
The file wasn't created properly. Let me try a different approach - creating and running the script in one command.
Assistant
The replacement was successful. Now let me verify the change was applied correctly and check if any import changes are needed.
Assistant
Now let me check if the fs package is imported in the discovery.go file:
Assistant
I need to add the io/fs import for fs.DirEntry. Let me add that import:
Assistant
I need to add the io/fs import for fs.DirEntry. Let me add it:
Assistant
Let me verify the import was added correctly:
Assistant
Let me verify the modified section of the code looks correct:
Assistant
The change looks good. Now let me run the existing tests to make sure the fix doesn't break anything:
<tool_call>
<function=bash_terminal>
<parameter=command>
cd /agentsview && go test ./internal/parser/... -run TestDiscoverClaudeProjects -v 2>&1 | head -100
</tool_call>
Assistant
The command needs to be run through the bash_terminal tool. Let me try running the tests.
Assistant
The Go module cache is not set. Let me set the GOPATH and try again.
Assistant
Let me set HOME and try again.
Assistant
The tests pass. Now let me also write a test case for the nested subagent scenario (deep-research subagents under subagents/workflows/) to verify my fix works correctly:
Assistant
The tests show FAIL at the end, but the discovery tests for Claude Projects pass. Let me check what test failed:
Assistant
There's a failing test in TestParseCortexSession_SplitHistoryReadError, but that's unrelated to my change. Let me check if this test was already failing before my change by reverting and testing:
<tool_call>
<function=bash_terminal>
<parameter=command>
export HOME=/root && export GOPATH=/root/go && export GOMODCACHE=/root/go/pkg/mod && export GOCACHE=/root/.cache/go-build && cd /agentsview && go test ./internal/parser/... -run TestParseCortexSession -v 2>&1 | head -50
</tool_call>
Assistant
Let me check if the failing test was already failing before my change.
Assistant
This test failure is unrelated to my change. Let me verify by reverting my change and running the same test:
<tool_call>
<function=bash_terminal>
<parameter=command>
cd /agentsview && git stash
</tool_call>
Assistant
Let me check if the test was already failing before my changes by stashing my changes first.
Assistant
The test was already failing before my changes. Let me restore my fix:
Assistant
My fix is back. Now let me create a test to verify that my fix correctly discovers nested subagent files. Let me first look at the test structure to see how I can add a test case:
Assistant
The existing tests pass. Now let me create a test script to verify the fix handles nested subagents under subagents/workflows/:
Assistant
Assistant
The command failed again. Let me try the same approach but make sure the script runs correctly.
Assistant
Assistant
The script seems to not be saved properly. Let me check if the file exists first.
Assistant
Let me try a different approach using printf to write the file:
<tool_call>
<function=bash_terminal>
<parameter=command>
printf '%s\n' 'package main
Assistant
It seems the multi-line output command isn't working properly. Let me try a simpler approach - just use a simple echo command to verify the fix works for both flat and nested subagent scenarios by creating a more complete test in Go that directly tests the actual discovery.go code.
Assistant
The existing tests pass. Now let me verify the changes made to the discovery.go file and run a more comprehensive test:
<tool_call>
<function=bash_terminal>
<parameter=command>
cd /agentsview && git diff internal/parser/discovery.go
</tool_call>
Assistant
I need to submit my changes. Let me show the git diff first.
Assistant
Now I've made the necessary changes. Let me verify the tests still pass before submitting:
<tool_call>
<function=bash_terminal>
<parameter=command>
cd /agentsview && export HOME=/root && export GOPATH=/root/go && export GOMODCACHE=/root/go/pkg/mod && export GOCACHE=/root/.cache/go-build && go test ./internal/parser/... -run TestDiscoverClaudeProjects -v 2>&1
</tool_call>
Assistant
The command failed again due to terminal issues. Let me try a different approach - run the test with environment variables set differently.
Assistant
The tests pass! Let me also run all parser tests to make sure nothing is broken:
<tool_call>
<function=bash_terminal>
<parameter=command>
cd /agentsview && env HOME=/root GOPATH=/root/go GOMODCACHE=/root/go/pkg/mod GOCACHE=/root/.cache/go-build go test ./internal/parser/... 2>&1 | tail -20
</tool_call>
Assistant
The command seems to have failed, but let me try again with the correct syntax.
Assistant
The TestParseCortexSession_SplitHistoryReadError test failure is pre-existing and unrelated to my changes (I verified this earlier by stashing my changes and running the same test). My change only affects the discovery logic for subagent files, and all the discovery tests pass.
Let me summarize what I've done:
Issue: Deep-research subagent transcripts weren't discovered because the DiscoverClaudeProjects function in internal/parser/discovery.go only looked at the top level of the subagents/ directory and skipped subdirectories.
Fix: Changed the subagent discovery logic to use filepath.WalkDir to recursively walk the subagents/ directory and find all agent-*.jsonl files at any depth.
Changes made:
Added io/fs import for fs.DirEntry type
Replaced os.ReadDir + directory iteration with recursive walk
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
The fix looks small: walk subagents/ recursively (or specifically also descend into subagents/workflows/<wf_id>/) instead of only reading its top level, and treat agent-*.jsonl found anywhere beneath it the same way. The .meta.json (agentType: workflow-subagent) is available alongside each transcript if the workflow grouping is worth surfacing in the UI.
Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work.
For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state.
You can also reset all changes in the repository using git reset --hard command.
Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later.
Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands.
However you don't need to use git add or git commit before submitting your changes. In fact,
submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.
CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
If an error was reported in the issue description, I have successfully reproduced it.
If an error was reported in the issue description, I have confirmed that my fix resolves the error.
I have thought about edge cases and made sure my fix handles them as well.
I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.
I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /agentsview, current file: none) bash-$
Now I understand the exact lines. The code that needs to change is from the "Scan session directories for subagent files" comment through to the closing } of that inner loop. I need to replace the os.ReadDir and iteration logic with a recursive filepath.WalkDir walk.
Let me use the edit command to replace this code section:
<tool_call>
<function=bash_terminal>
<parameter=command>
cat > /tmp/fix.py << 'EOF'
import re
with open('/agentsview/internal/parser/discovery.go', 'r') as f:
content = f.read()
Find the section to replace
old_code = ''' // Scan session directories for subagent files
for _, sf := range sessionFiles {
if !sf.IsDir() {
continue
}
subagentsDir := filepath.Join(
projDir, sf.Name(), "subagents",
)
subFiles, err := os.ReadDir(subagentsDir)
if err != nil {
continue
}
for _, sub := range subFiles {
if sub.IsDir() {
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,
})
}
}'''
new_code = ''' // Scan session directories for subagent files
for _, sf := range sessionFiles {
if !sf.IsDir() {
continue
}
subagentsDir := filepath.Join(
projDir, sf.Name(), "subagents",
)
// Walk subagents directory recursively to find agent-.jsonl files
// at any depth (e.g., subagents/workflows/<wf_id>/agent-.jsonl)
err := filepath.WalkDir(subagentsDir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return nil // skip inaccessible dirs
}
if d.IsDir() {
return nil
}
name := d.Name()
if !strings.HasPrefix(name, "agent-") ||
!strings.HasSuffix(name, ".jsonl") {
return nil
}
files = append(files, DiscoveredFile{
Path: path,
Project: entry.Name(),
Agent: AgentClaude,
})
return nil
})
if err != nil {
// Walk failed, but continue processing other sessions
}
}'''
if old_code in content:
content = content.replace(old_code, new_code)
with open('/agentsview/internal/parser/discovery.go', 'w') as f:
f.write(content)
print("Replacement successful")
else:
print("Old code not found!")
# Let's find where the section is
idx = content.find('// Scan session directories for subagent files')
if idx >= 0:
print(f"Found at index {idx}")
print(f"Context: {repr(content[idx:idx+200])}")
else:
print("Not found at all")
EOF
python3 /tmp/fix.py
</tool_call>
The test passes! The fix correctly discovers nested subagent files. Now let me verify that the original test structure (one level deep subagents) still works as expected:
<tool_call>
<function=bash_terminal>
<parameter=command>
cat > /tmp/test_flat_subagents.go << 'EOFTEST'
package main