|
|
---
|
|
|
# claudbg-33n0
|
|
|
title: Agent discovery looks in wrong subagents directory — sessions show 0 agents
|
|
|
status: completed
|
|
|
type: bug
|
|
|
priority: high
|
|
|
created_at: 2026-03-30T04:43:21Z
|
|
|
updated_at: 2026-03-30T05:01:30Z
|
|
|
---
|
|
|
|
|
|
## 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 198–205), `discover_all_agents` (lines 211–266), `collect_agents_in_dir`
|
|
|
- `src/commands/agents.rs` — integration tests
|
|
|
|
|
|
## Summary of Changes
|
|
|
|
|
|
- Fixed in to use to derive the sibling directory
|
|
|
- Fixed to iterate UUID subdirectories inside each project dir and call on each
|
|
|
- Updated tests in (, ) to create agent files at the correct path structure
|