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
I'll start by exploring the repository structure to understand the codebase and locate the relevant files mentioned in the issue.
Assistant
This looks like a Go project. The issue mentions
internal/parser/discovery.go, so let me explore that file to understand the current implementation.<tool_call> <function=bash_terminal> <parameter=command> find . -name "discovery.go" -type f </tool_call>
Assistant
Let me search for the discovery.go file in the repository.
Assistant
Good, I found the file. Let me open it to understand the current implementation.
<tool_call> <function=open> <parameter=file> ./internal/parser/discovery.go </tool_call>
Assistant
Let me properly use the open command with the file path.
Assistant
The command seems to be having issues. Let me just use cat or grep to read the file content directly.
<tool_call> <function=bash_terminal> <parameter=command> cat ./internal/parser/discovery.go </tool_call>
Assistant
It seems my commands aren't being invoked properly. Let me try a simpler approach with a basic command first.
Assistant
The file is quite long. The issue mentions that around line 359 there's code that skips directories in the subagents folder. Let me search for that specific section of the code related to subagents.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "subAgents|subagents" ./internal/parser/discovery.go | head -50 </tool_call>
Assistant
Let me search for the subagents-related code in the discovery.go file.
Assistant
Let me look at the code around lines 347-380 to see the current implementation that needs to be fixed.
Assistant
Now let me look at the full function to understand its structure better:
Assistant
Let me find the function name for this function and also look at any related functions to understand the pattern better.
Assistant
Now I understand the issue. The
DiscoverClaudeProjectsfunction only reads the top level of thesubagentsdirectory and skips subdirectories. The fix is to recursively walk thesubagentsdirectory to findagent-*.jsonlfiles at any depth.Let me also check if there are any test files or sample data to understand the expected structure better:
Assistant
Let me search for existing tests related to the discovery functions.
Assistant
Let me look at the discovery tests to understand how the function is tested and what the expected behavior is.
Assistant
Now I understand the test structure. Looking at the test "Subagents" case in
TestDiscoverClaudeProjects, it only tests for subagent files directly undersubagents/. The issue is that deep-research creates subagent files one level deeper undersubagents/workflows/<wf_id>/.Let me look at the complete function to understand the full context:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '308,385p' ./internal/parser/discovery.go </tool_call>
Assistant
Let me try to read the file content in smaller chunks using the bash_terminal command.
Assistant
Now I can see the full function. The issue is on lines 359-360 where
if sub.IsDir() { continue }- this skips subdirectories, so the nestedworkflows/directory is never explored.I need to replace this loop with a recursive walk that finds all
agent-*.jsonlfiles under thesubagents/directory at any depth.Let me also check if there's a
FindClaudeSourceFilefunction that needs to be updated as well:<tool_call> <function=bash_terminal> <parameter=command> grep -n "FindClaudeSourceFile" ./internal/parser/discovery.go </tool_call>
Assistant
The grep command didn't work. Let me try running it properly as a command.
Assistant
Let me check the
FindClaudeSourceFilefunction to see if it also needs updating:Assistant
Now I see that
FindClaudeSourceFilealso has a similar issue at lines 464-485 - it only looks one level deep insubagents/and doesn't recursively search for agent files nested undersubagents/workflows/<wf_id>/.I need to fix both:
DiscoverClaudeProjects- to recursively find allagent-*.jsonlfiles undersubagents/FindClaudeSourceFile- to also recursively search for subagent files
Let me now write the fix. I'll use
filepath.WalkDirto recursively walk thesubagentsdirectory and find allagent-*.jsonlfiles.Let me first run the existing tests to see their baseline:
<tool_call> <function=bash_terminal> <parameter=command> cd /agentsview && go test -v ./internal/parser/... -run TestDiscoverClaudeProjects 2>&1 </tool_call>
Assistant
Let me run the tests properly. The command needs to be properly formatted.
Assistant
Let me set up the Go environment properly:
Assistant
The environment is not set up for running Go tests. Let me focus on fixing the code directly. I'll use the edit command to fix the
DiscoverClaudeProjectsfunction to recursively walk subagent directories.Assistant
The tests pass. Now let me also verify the test for nested workflows (the deep-research scenario) to ensure the fix will work. First, let me create a test script to verify the current behavior:
Assistant
Let me create the test within the testdata or another way to test the functionality:
<tool_call> <function=bash_terminal> <parameter=command> cat > /agentsview/internal/parser/nested_test.go << 'EOF' package parser
import ( "path/filepath" "testing" )
// TestDiscoverClaudeProjects_NestedSubagents tests that deep-research // subagent transcripts nested under subagents/workflows/<wf_id>/ are discovered. func TestDiscoverClaudeProjects_NestedSubagents(t *testing.T) { files := map[string]string{ // Direct subagent (traditional style) filepath.Join("project-a", "parent-session", "subagents", "agent-direct.jsonl"): "{}", // Nested subagents (deep-research style) filepath.Join("project-a", "session-1", "subagents", "workflows", "wf-abc", "agent-001.jsonl"): "{}", filepath.Join("project-a", "session-1", "subagents", "workflows", "wf-abc", "agent-002.jsonl"): "{}", filepath.Join("project-a", "session-2", "subagents", "workflows", "wf-def", "agent-003.jsonl"): "{}", // Non-agent file should be ignored filepath.Join("project-a", "session-1", "subagents", "not-agent.jsonl"): "{}", // Auxiliary file filepath.Join("project-a", "session-1", "subagents", "workflows", "wf-abc", "agent-001.meta.json"): "{}", }
Assistant
Let me run the test command properly.
Assistant
The test didn't run. Let me check if the test file was created properly:
<tool_call> <function=bash_terminal> <parameter=command> ls -la /agentsview/internal/parser/nested_test.go </tool_call>
Assistant
The command seems to not be getting invoked properly. Let me try a different approach - just run ls to verify the file exists.
Assistant
The file wasn't created. The heredoc approach seems to have failed. Let me try a simpler approach using echo and redirect.
<tool_call> <function=bash_terminal> <parameter=command> cat > /agentsview/internal/parser/nested_test.go << 'ENDOFFILE' package parser
import ( "path/filepath" "testing" )
// TestDiscoverClaudeProjects_NestedSubagents tests that deep-research // subagent transcripts nested under subagents/workflows/<wf_id>/ are discovered. func TestDiscoverClaudeProjects_NestedSubagents(t *testing.T) { files := map[string]string{ // Direct subagent (traditional style) filepath.Join("project-a", "parent-session", "subagents", "agent-direct.jsonl"): "{}", // Nested subagents (deep-research style) filepath.Join("project-a", "session-1", "subagents", "workflows", "wf-abc", "agent-001.jsonl"): "{}", filepath.Join("project-a", "session-1", "subagents", "workflows", "wf-abc", "agent-002.jsonl"): "{}", filepath.Join("project-a", "session-2", "subagents", "workflows", "wf-def", "agent-003.jsonl"): "{}", // Non-agent file should be ignored filepath.Join("project-a", "session-1", "subagents", "not-agent.jsonl"): "{}", // Auxiliary file filepath.Join("project-a", "session-1", "subagents", "workflows", "wf-abc", "agent-001.meta.json"): "{}", }
Assistant
It seems the heredoc command is not working properly. Let me try a different approach - using echo with multiple lines or using a simpler method to create the test file.
Assistant
The echo approach worked. Let me continue building the test file piece by piece.
<tool_call> <function=bash_terminal> <parameter=command> echo '' >> /agentsview/internal/parser/nested_test.go && echo '// TestDiscoverClaudeProjects_NestedSubagents tests that deep-research' >> /agentsview/internal/parser/nested_test.go && echo '// subagent transcripts nested under subagents/workflows/<wf_id>/ are discovered.' >> /agentsview/internal/parser/nested_test.go && echo 'func TestDiscoverClaudeProjects_NestedSubagents(t *testing.T) {' >> /agentsview/internal/parser/nested_test.go </tool_call>
Assistant
The echo approach is working but is tedious. Let me try a more efficient approach - using tee or writing the file using printf or using sed to add content. Actually, let me try using a single cat command with proper escaping.
Assistant
The heredoc command seems to have worked this time. Let me verify the test file was created and run it:
<tool_call> <function=bash_terminal> <parameter=command> cat /agentsview/internal/parser/nested_test.go </tool_call>
Assistant
Let me run cat to check the test file content.
Assistant
The test file is missing the
funcdeclaration and has some structural issues. Let me recreate it properly:<tool_call> <function=bash_terminal> <parameter=command> rm /agentsview/internal/parser/nested_test.go </tool_call>
Assistant
Let me try using printf to create the test file more reliably.
Assistant
Good. Let me verify the test file:
Assistant
Good! The test file looks correct. Now let me run the test to confirm it fails with the current implementation (which should skip nested directories):
Assistant
The test fails as expected, confirming the issue - only 1 file was found (direct subagent) instead of 4 (including nested ones under
workflows/).Now let me fix the
DiscoverClaudeProjectsfunction to recursively walk thesubagentsdirectory:Assistant
Now let me fix the
DiscoverClaudeProjectsfunction by replacing the simple loop with a recursive walk:Assistant
Now I need to replace the code that only reads the first level of
subagents/with code that recursively walks the directory. Let me use the edit command to make this change.Assistant
Let me try using the bash_editor tool or a different approach. First, let me create the fixed version of the code section:
Assistant
Now let me verify the new file looks correct:
Assistant
Let me check if
filepathandosare already imported:Assistant
Both
osandfilepathare already imported. Good. Now let me copy the new file to replace the original:<tool_call> <function=bash_terminal> <parameter=command> cp /tmp/discovery_new.go /agentsview/internal/parser/discovery.go </tool_call>
Assistant
Let me run the copy command properly.
Assistant
Now let me run the test to verify that the fix works:
Assistant
Now let me also check and fix the
FindClaudeSourceFilefunction which has the same issue. Let me view it:Assistant
Now I need to fix
FindClaudeSourceFileto also recursively search for subagent files undersubagents/workflows/<wf_id>/. Let me get more lines to see the full function:Assistant
Now let me create a fixed version of
FindClaudeSourceFileto also handle nested subagent directories:Assistant
The function ends around line 487. Let me create a new file with the fixed
FindClaudeSourceFilefunction:Assistant
Actually, I realize my
filepath.WalkDirapproach inFindClaudeSourceFileis not quite right - I need a better implementation. Let me think about this more carefully. The issue is that we want to find a specific file namedsessionID + ".jsonl"under the subagents directory at any depth.Let me rewrite the function more cleanly:
Assistant
Let me now add a cleaner implementation of
FindClaudeSourceFile:<tool_call> <function=bash_terminal> <parameter=command> cat >> /tmp/discovery_fixed.go << 'CODEEND'
// FindClaudeSourceFile finds the original JSONL file for a Claude // session ID by searching all project directories. func FindClaudeSourceFile( projectsDir, sessionID string, ) string { if !IsValidSessionID(sessionID) { return "" }
codeAssistant
Let me run this command properly.
Assistant
Now let me append the rest of the file:
<tool_call> <function=bash_terminal> <parameter=command> cd /agentsview && tail -n +487 ./internal/parser/discovery.go >> /tmp/discovery_fixed.go </tool_call>
Assistant
Let me run this command to append the rest of the file.
Assistant
Now let me verify the file looks correct by checking the function:
<tool_call> <function=bash_terminal> <parameter=command> cd /agentsview && sed -n '430,500p' /tmp/discovery_fixed.go </tool_call>
Assistant
Let me try again with the bash terminal command.
Assistant
The file looks good. Now let me copy it to replace the original:
Assistant
Let me verify the file compiles correctly:
<tool_call> <function=bash_terminal> <parameter=command> cd /agentsview && go build ./internal/parser/... </tool_call>
Assistant
Let me run the build command properly to check if the code compiles.
Assistant
There's a syntax error. Let me check line 509 and the surrounding context:
<tool_call> <function=bash_terminal> <parameter=command> cd /agentsview && sed -n '495,525p' ./internal/parser/discovery.go </tool_call>
Assistant
Let me check the code around line 509 to find the syntax error.
Assistant
I see the issue - there's duplicate code from my previous edits. Let me fix this by removing the duplicate function:
Assistant
I see the issue - there's duplicate code between lines 506-514. Let me recreate the file properly by extracting the correct sections.
Assistant
The file has 2129 lines but the original should be around 1750. Let me restore from git and then make the changes properly:
<tool_call> <function=bash_terminal> <parameter=command> cd /agentsview && git checkout ./internal/parser/discovery.go </tool_call>
Assistant
Let me restore the original file and then carefully make the changes.
Assistant
Good. Now let me make the changes more carefully. First, let me see the exact line numbers for the section I need to change in
DiscoverClaudeProjects:Assistant
Now let me use the edit tool to replace the subagent scanning section in
DiscoverClaudeProjects:Assistant
Let me try a different approach using sed to replace the code block:
Assistant
Now let me verify the changes were applied correctly:
Assistant
The script didn't work perfectly - there's duplicate code and leftover old code. Let me restore from git and try a cleaner approach:
<tool_call> <function=bash_terminal> <parameter=command> git checkout ./internal/parser/discovery.go </tool_call>
Assistant
Let me restore from git again and try a cleaner Python script to fix the code.
Assistant
Let me write a better Python script that handles the replacement correctly:
Assistant
Now let me verify the changes:
Assistant
I see the outer loop was removed. Let me fix this properly by restoring and using a more precise approach:
Assistant
Let me look at the exact structure of the original code more carefully:
Assistant
Let me write a more precise Python script to fix only the inner loop:
Assistant
Now let me verify the changes:
Assistant
Now let me run the test to verify the fix works:
Assistant
I need to remove the unused
subFilesvariable. Let me fix that:Assistant
Let me verify the changes:
Assistant
Now let me run the test:
Assistant
The test passes. Now let me run the existing
TestDiscoverClaudeProjectstests to make sure I didn't break anything:Assistant
All tests pass. Now let me also fix the
FindClaudeSourceFilefunction. Let me check the exact lines again:<tool_call> <function=bash_terminal> <parameter=command> sed -n '435,490p' /agentsview/internal/parser/discovery.go </tool_call>
Assistant
Let me run the sed command again to view the FindClaudeSourceFile function.
Assistant
Now let me fix the
FindClaudeSourceFilefunction to handle nested subagent directories:Assistant
Now let me verify the changes:
Assistant
The
FindClaudeSourceFilefunction is now fixed. Let me compile and run the tests to verify everything works:Assistant
Good, the code compiles. Now let me run all the parser tests:
Assistant
Let me also run the FindClaudeSourceFile tests to make sure those still pass:
<tool_call> <function=bash_terminal> <parameter=command> cd /agentsview && go test -v ./internal/parser/... -run TestFindClaudeSourceFile </tool_call>
Assistant
The command to run the tests was not properly executed. Let me try again.
Assistant
All tests pass. Now let me also add a test for
FindClaudeSourceFilewith nested subagents:Assistant
Now let me run the new test:
Assistant
Excellent! The new test passes. Now let me run all the tests in the parser package to make sure I haven't broken anything:
Assistant
There's a pre-existing test failure in
TestParseCortexSession_SplitHistoryReadError. Let me check if this test failure existed before my changes:Assistant
Let me check if that failing test existed before my changes by temporarily reverting and running the test:
<tool_call> <function=bash_terminal> <parameter=command> git stash && go test ./internal/parser/... -run TestParseCortexSession_SplitHistoryReadError </tool_call>
Assistant
Let me try running the command to check if the test failure existed before my changes.
Assistant
Good - the test failure existed before my changes. Let me restore my changes and continue:
<tool_call> <function=bash_terminal> <parameter=command> git stash pop </tool_call>
Assistant
The git stash pop command wasn't properly invoked. Let me run it again.
Assistant
Good, my changes are back. Now let me run the parser tests again, excluding the pre-existing failing test to verify my changes don't introduce new failures:
<tool_call> <function=bash_terminal> <parameter=command> go test ./internal/parser/... -run "^((?!TestParseCortexSession_SplitHistoryReadError).)*$" </tool_call>
Assistant
The command failed. Let me try a different approach - running all tests except that specific one using grep or excluding the failing test.
Assistant
Let me try a simpler approach - just run the tests related to discovery and Claude:
Assistant
All discovery-related tests pass. Now let me run more tests to check for any issues:
Assistant
Good. Let me also run the OpenCode and Gemini tests:
Assistant
All tests pass except for the pre-existing failing test. Now let me clean up the test file and verify the changes one more time:
Assistant
The changes look good. Let me also view the test file I added:
Assistant
The test file looks good. Let me run all the tests one more time to ensure everything passes:
Assistant
All tests pass! Let me also make sure the full test suite doesn't fail with my changes except for the pre-existing failing test. Let me run a few more test runs to confirm:
Assistant
Only the pre-existing test failure remains. The fix is complete. Let me create a summary of the changes made:
Summary
I've fixed the issue where deep-research / workflow subagent transcripts nested under
subagents/workflows/<wf_id>/were not being discovered by the agentsview parser.Changes Made:
-
DiscoverClaudeProjectsfunction (internal/parser/discovery.go):- Changed from using
os.ReadDirwhich only reads the first level of thesubagentsdirectory - Replaced with
filepath.WalkDirto recursively walk all subdirectories undersubagents - This now discovers agent files at any depth, including
subagents/workflows/<wf_id>/agent-*.jsonl
- Changed from using
-
FindClaudeSourceFilefunction (internal/parser/discovery.go):
-
Assistant
The test file has 71 lines which is reasonable for testing the nested subagent scenarios. Let me now submit the changes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.