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 analyze the issue:
- The problem is in
internal/parser/discovery.gowhereDiscoverClaudeSessionsonly looks for subagent transcripts one level down insubagents/directory - Deep-research writes subagent transcripts deeper:
subagents/workflows/<wf_id>/agent-<id>.jsonl - The current code skips directories, so it never descends into
subagents/workflows/ - The fix should walk recursively or specifically handle the nested structure
Let me start by exploring the repository structure and understanding the code.
- The problem is in
Assistant
Let me find the discovery.go file mentioned in the issue.
<tool_call> <function=bash_terminal> <parameter=command> find /agentsview -type f -name "discovery.go" 2>/dev/null </tool_call> <tool_call> <function=bash_terminal> <parameter=command> ls -la /agentsview/internal/parser/ </tool_call> <tool_call> <function=bash_terminal> <parameter=command> find /agentsview -path "/parser/discovery" 2>/dev/null </tool_call>
Assistant
I need to make proper tool calls. Let me search for the discovery.go file and explore the parser directory.
Assistant
Found it. Let me look at the discovery.go file.
Assistant
The file was truncated. Let me look at the subagent-related code around line 359.
Assistant
Let me view the subagent-related code in context:
Assistant
Let me see the full
DiscoverClaudeSessionsfunction:Assistant
The grep didn't find the function name, but I can see the code that scans for subagent files around line 347. Let me look at the broader context to understand the full function and how to fix it.
Assistant
Now I understand the issue. The
DiscoverClaudeProjectsfunction (around lines 310-385) reads thesubagents/directory but only processes files at the top level — it skips directories entirely (if sub.IsDir() { continue }), so it never descends intosubagents/workflows/<wf_id>/.Let me also check the
FindClaudeSourceFilefunction since it has a similar issue:Assistant
Now I understand the issue clearly. Let me examine the existing tests and understand the codebase better before making changes.
Assistant
Let me check the discovery tests to understand the expected behavior better.
Assistant
Now let me also check the subagent test file:
<tool_call> <function=bash_terminal> <parameter=command> cat /agentsview/internal/parser/claude_subagent_test.go </tool_call>
Assistant
Let me run the command properly.
Assistant
Now I have a clear understanding of the issue. Let me run the existing tests first to confirm they pass:
Assistant
The Go environment doesn't have a proper module cache set. Let me check the Go setup.
Assistant
Let me set up the Go environment properly.
Assistant
The
HOMEenvironment variable is not defined. Let me set it.Assistant
Now I have a clear picture. Let me write a reproduction script first to confirm the issue, then fix it.
Assistant
Let me create a test script within the project structure instead:
Assistant
I've confirmed the issue. Now let me fix the code. I need to modify
DiscoverClaudeProjectsto recursively walk thesubagents/directory instead of only processing files at the top level. I should also fixFindClaudeSourceFilewhich has a similar issue.Let me look at the full discovery.go file to understand the line numbers better:
Assistant
Let me look at the exact code section I need to modify:
Assistant
Now I understand the full context. I need to fix the code to recursively walk the
subagents/directory. Let me make the changes:Assistant
Now I understand the issue. The current code at lines 347-376 only reads the top level of
subagents/and skips directories, so it never descends intosubagents/workflows/<wf_id>/. I need to change this to recursively walk thesubagents/directory.Let me apply the fix:
Assistant
I need to use the proper edit command format. Let me use the correct format with the
editcommand and--fileoption.Assistant
Now let me use the proper edit command format:
Assistant
Let me use a simpler approach with a temp file:
Assistant
Let me verify the file was properly constructed and then run the test.
Assistant
The code looks correct. Now let me verify the file compiles and run the test:
Assistant
The code compiles. Now let me run the test to verify the fix works.
Assistant
The fix works for
DiscoverClaudeProjects. Now I need to also check and fixFindClaudeSourceFilewhich has a similar issue. Let me look at it:Assistant
Let me look at the
FindClaudeSourceFilefunction and fix it similarly:Assistant
I need to fix the
FindClaudeSourceFilefunction as well. Let me see the complete function first.Assistant
Now I need to fix
FindClaudeSourceFileas well to handle nested subagent files. Let me look at the exact lines I need to replace:Assistant
Let me verify the file is well-formed:
Assistant
I see there are issues - duplicate comments and code remnants. Let me look at the current state and fix it properly:
Assistant
The file has issues - duplicate code and comments. Let me restore from git and redo this properly.
Assistant
Let me start fresh and carefully examine the exact state of the file:
Assistant
Let me carefully examine the exact code block and use a more precise approach:
Assistant
Now I understand the issue completely. Let me fix both functions properly. First, let me fix
DiscoverClaudeProjects:Assistant
Let me use a different approach with a Python script to make the edit:
Assistant
Now let me verify the first fix and then fix the second function (
FindClaudeSourceFile):Assistant
The first fix is in place. Now let me fix
FindClaudeSourceFile:Assistant
Let me look at the FindClaudeSourceFile function and make the proper edit to handle nested subagent files. I need to replace the flat lookup with a recursive WalkDir approach.
Assistant
Now let me fix
FindClaudeSourceFileto handle nested subagent files:Assistant
Now let me verify both changes compiled correctly and run the tests:
Assistant
The code compiles. Now let me run the reproduction test and the existing tests:
Assistant
The nested subagent discovery works. Now let me run the existing tests:
Assistant
Let me run the
FindClaudeSourceFiletests as well:Assistant
All existing tests pass. Let me also run all parser tests to make sure there are no regressions:
Assistant
The user wants me to continue running the tests and make sure everything passes. Let me run the full parser tests to completion.
Assistant
This test failure (
TestParseCortexSession_SplitHistoryReadError) is unrelated to my changes - it's about a cortex parser read error, not about Claude subagent discovery. Let me verify it was failing before my changes:Assistant
Good - this test failure existed before my changes. It's a pre-existing issue in the repository. Let me restore my changes:
Assistant
Good - the pre-existing test failure is unrelated to my changes. Let me run the parser tests excluding that pre-existing failing test to confirm my changes work correctly:
Assistant
All discovery and Claude-related tests pass. Let me run the full reproduction test again and clean up:
Assistant
Let me test a few more edge cases to make sure the fix is robust:
Assistant
All edge case tests pass. Let me clean up the test files and verify the final diff before submitting:
Assistant
Let me verify the final diff and run the relevant tests one more time:
Assistant
The diff looks correct. Let me run the final verification tests:
Assistant
The fix has been fully verified. Here's a summary of what was done:
Summary
The issue was in
internal/parser/discovery.gowhere bothDiscoverClaudeProjectsandFindClaudeSourceFileonly scanned the top level of thesubagents/directory. When a directory entry was encountered (likesubagents/workflows/), the code wouldcontinueand skip it entirely, never descending into it.Changes Made
-
DiscoverClaudeProjects(lines 347-377): Replacedos.ReadDir+ flat loop withfilepath.WalkDirto recursively walk the entiresubagents/tree, discoveringagent-*.jsonlfiles at any depth. -
FindClaudeSourceFile(lines 460-495): Updated the subagent lookup to usefilepath.WalkDirinstead of a single-levelos.Statcheck, enabling it to find nested agent files while maintaining backward compatibility with flat subagent locations.
Edge Cases Handled
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.