You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
claudbg/.beans/claudbg-33n0--agent-discove...

64 lines
2.2 KiB
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
# claudbg-33n0
title: Agent discovery looks in wrong subagents directory — sessions show 0 agents
status: todo
type: bug
priority: high
created_at: 2026-03-30T04:43:21Z
updated_at: 2026-03-30T04:43:21Z
---
## Problem
`agents list <session-id>` always returns empty results. The subagent directory path used in discovery is wrong.
## Root cause
`discover_agents_for_session(session_file)` in `src/parser/discovery.rs:198-205` does:
```rust
let parent = session_file.parent(); // ~/.claude/projects/<project-dir>/
let subagents_dir = parent.join("subagents"); // ~/.claude/projects/<project-dir>/subagents/
```
That directory never exists.
`discover_all_agents()` has the same bug: it iterates project dirs and looks at `proj_path.join("subagents")` directly — also wrong.
## Actual disk structure
Confirmed across multiple sessions in the live `~/.claude/projects/` dir:
```
~/.claude/projects/<project-dir>/
<session-uuid>.jsonl ← session file
<session-uuid>/ ← directory with same name as UUID (no .jsonl)
subagents/
agent-<id>.jsonl
agent-<id>.meta.json
```
Example path that should work but currently returns empty:
`~/.claude/projects/.../def4776b-25a6-4eca-99e7-f222926c297a/subagents/agent-a8e741de240089eef.jsonl`
## Required fix
`discover_agents_for_session(session_file)` should construct:
```rust
let stem = session_file.file_stem().unwrap(); // "def4776b-...-f222926c297a"
let session_dir = session_file.parent().unwrap().join(stem);
let subagents_dir = session_dir.join("subagents");
```
`discover_all_agents()` must also be updated to walk UUID subdirectories inside each project dir instead of looking at `<project-dir>/subagents/` directly.
## Secondary issue
The existing unit tests in `src/commands/agents.rs` (`dump_with_real_agent_returns_ok`, `transcribe_with_real_agent_returns_ok`) create subagents at the old wrong path (`projects/subagents/`) and must be updated alongside the fix.
## Relevant files
- `src/parser/discovery.rs``discover_agents_for_session` (lines 198205), `discover_all_agents` (lines 211266), `collect_agents_in_dir`
- `src/commands/agents.rs` — integration tests