fix(convo-miner): skip Claude Code subagent transcripts by default (#1217) - #1330
Conversation
|
Hi, Severity: remediation recommended | Category: reliability How to fix: Use getattr with default Agent prompt to fix - you can give this to your LLM of choice:
Found by Qodo code review |
f00d9b9 to
1f4cc8b
Compare
01d5ee3 to
f7d3790
Compare
e88126f to
df83681
Compare
ea71ca2 to
cf652ab
Compare
e273d37 to
83a9f86
Compare
49a7340 to
cef1369
Compare
cef1369 to
c7a7787
Compare
c7a7787 to
6f82262
Compare
ccac056 to
c564c59
Compare
c564c59 to
7e6e8e0
Compare
…emPalace#1217) scan_convos() now prunes any directory named 'subagents' during os.walk. Claude Code records Explore/Plan/Grep subagent transcripts in <session-uuid>/subagents/agent-*.jsonl and on a typical workspace these outweigh main session files ~80:1, dominating mining time and producing near-zero additional signal (the parent session already summarizes them). Adds a --include-subagents opt-in flag for users who want full history. The shared SKIP_DIRS set in palace.py is left untouched, so project mining (miner.scan_project) still descends into legitimate user-created subagents/ directories in code projects.
- Case-insensitive directory match (d.lower() == 'subagents') so the filter still kicks in if Claude Code or a plugin ever emits 'Subagents/' on case-preserving filesystems (Windows, macOS APFS). - Drop defensive getattr in cmd_mine: argparse always defines the attribute since --include-subagents is unconditionally registered. Direct args.include_subagents access matches every neighbouring field and fails loudly if the registration is ever removed. - Soften CLI help and docstring: drop the 80:1 ratio (reporter- specific) and the in-code (MemPalace#1217) reference. Add explicit default=False on the argparse flag for symmetry with --extract. - Add 2 negative tests: 'mysubagents'/'subagentsbackup' must still be mined (regression guard against substring-match), and 'Subagents/' must be skipped (case-insensitive coverage).
7e6e8e0 to
a3350ec
Compare
…gets The default `subagents/` skip is directory pruning, so it cannot reach a caller who names one transcript directly: that path feeds a single synthetic scan entry with no directories to prune. The split is deliberate -- `--include-subagents` governs what a directory walk sweeps up, while naming a path stays an explicit request -- but the single-file scan and this filter were written independently and nothing exercised them together, so the boundary was unpinned.
49b06fc to
5bc539d
Compare
igorls
left a comment
There was a problem hiding this comment.
Wave 1 for 3.7.0: LGTM. Focused fix with tests (or trivial deploy/manifest change). Merging into develop for the release train.
Problem
mempalace mine --mode convoswalks~/.claude/projects/<slug>/recursivelyand picks up every
.jsonlfile, including those inside<session-uuid>/subagents/where Claude Code records Explore/Plan/Grep subagent transcripts.
Reporter data on issue #1217 (49 projects, 2 months of usage):
summarized in the parent session
Smoke-tested against a real Claude Code project directory: 21 main + 92
subagent jsonl files (5x ratio), default-skip drops 38% of mined files with
no signal loss.
Fix
scan_convos()now skips any directory namedsubagentsby default. New--include-subagentsflag re-enables them for users who want full history.The filter is applied inside
convo_miner.scan_convos's directorypruning (the same place
SKIP_DIRSis consulted). Pruning governs adirectory walk only, so a transcript named directly --
mine <session>/subagents/agent-x.jsonl-- is still mined without--include-subagents. That split is deliberate: the flag decides what awalk sweeps up, while naming a path stays an explicit request.
The shared
SKIP_DIRSset inpalace.pyis left untouched, so projectmining (
miner.scan_project) still descends into user-createdsubagents/Python modules in regular code projects.Files
mempalace/convo_miner.py--scan_convos(include_subagents=False)parameter, threaded from
mine_convos()mempalace/cli.py-- new--include-subagentsflag onmine,forwarded through
cmd_minetomine_convostests/test_convo_miner_unit.py-- 6 new tests (default skip, opt-in,any-depth match, suffix-named directories left alone, case-insensitive
match, and an explicitly named file inside
subagents/)tests/test_cli.py-- existingtest_cmd_mine_convos_modeupdatedfor the new kwarg, new test pinning the flag-threading path
Verification
End-to-end smoke test against a real Claude Code project directory:
Difference = 92, matches
find <claude-projects-dir> -path '*/subagents/*.jsonl' | wc -l.Out of scope
tool-results/directories -- already covered by the existing.meta.jsonfilename filter (no.jsonlfiles there).and a larger surface; default-skip + opt-in flag is the cleaner UX.
.mempalaceignore(feat: default-exclude runtime-state files + per-file drawer cap to prevent ingestion noise #587) -- orthogonal: a future ignore-filemechanism would let users override the default if needed, but the
default-safe path here is additive and doesn't conflict.