Skip to content

fix(band): keep readable subagent usage during partial imports - #1461

Merged
DietrichGebert merged 1 commit into
DietrichGebert:mainfrom
Afloat16:fix/band-partial-subagent-import-20261119
Nov 22, 2026
Merged

DietrichGebert merged 1 commit into
DietrichGebert:mainfrom
Afloat16:fix/band-partial-subagent-import-20261119

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Fixes #1460

Problem

Band import reads all subagent transcripts inside one flatMap assignment. If any transcript cannot be opened or read, the assignment never completes and the outer catch leaves the entire subagent list empty. The session is still imported, but the ledger silently loses the token usage and estimated cost of every readable subagent.

Change

Handle a read failure inside each subagent file's callback. An unreadable subagent is skipped while other readable files continue through the existing message-ID deduplication and cost accounting. Directory enumeration failures retain the existing best-effort behavior.

The filesystem regression places a non-readable transcript entry between two valid subagent transcripts, runs the actual importer and verifies the saved total-token, output-token and cost columns. It also preserves the existing second-import deduplication check. Before the fix, the expected 14,850 tokens were recorded as 6,600 because both healthy subagents disappeared.

Validation

  • New filesystem regression against unchanged production code: fails with 6,600 actual versus 14,850 expected tokens.
  • node --test tests/band-import.test.js: passed after the fix.
  • npm test: 144 root tests and 30 pi-extension tests passed.
  • node scripts/check-rule-copies.js, node scripts/check-versions.js and git diff --check: passed.
  • Node.js 24.22.3 with pandas 2.2.3 on Linux, with a writable temporary directory; unrelated host configuration environment variables were removed from the test subprocess.

Related history checked: #1196 handles malformed main-transcript cwd data, temporary-path matching and file-handle cleanup; it does not isolate failures while collecting subagent transcripts.

Unreadable transcript contents remain unavailable and cannot be recovered by this change. No live Claude Code session was imported; validation uses synthetic local transcript files through the real importer.

@DietrichGebert

Copy link
Copy Markdown
Owner

Thanks! Tested it, works. Merged, will be in the next release.

@DietrichGebert
DietrichGebert merged commit affbac1 into DietrichGebert:main Nov 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Band import drops healthy subagent usage when another transcript cannot be read

2 participants