Skip to content

fix(ce-compound): detect Claude sessions with long metadata preambles in extract-skeleton#1082

Merged
tmchow merged 1 commit into
EveryInc:mainfrom
LukeTheoJohnson:fix-extract-skeleton-detection-cap
Jul 9, 2026
Merged

fix(ce-compound): detect Claude sessions with long metadata preambles in extract-skeleton#1082
tmchow merged 1 commit into
EveryInc:mainfrom
LukeTheoJohnson:fix-extract-skeleton-detection-cap

Conversation

@LukeTheoJohnson

Copy link
Copy Markdown
Contributor

Fixes #923

Summary

extract-skeleton.py caps platform auto-detection at the first 10 lines. Current Claude Code session files front-load more than 10 metadata records before the first user/assistant message, so detection never fires, the file falls through to the codex handler, and the script returns an empty skeleton with parse_errors: 0. It reads as "no relevant prior sessions" rather than a bug, which disables session-history synthesis silently.

The issue was filed against ce-sessions; the script now lives at skills/ce-compound/scripts/session-history/extract-skeleton.py and the cap is still present there. A prior PR (#958) predated that move and was closed; this PR applies the fix at the script's current location.

Current behavior

Piping a session with a 12-record metadata preamble (the record types observed in #923: last-prompt, custom-title, agent-name, mode, permission-mode, attachments) followed by the repo's own claude-session.jsonl fixture through the script:

{"_meta": true, "lines": 22, "parse_errors": 0, "user": 0, "assistant": 0, "tool": 0, "summary": 0}

22 lines read, zero errors reported, nothing extracted.

Fix

Drop the cap: if not detected and len(buffer) <= 10: becomes if not detected:, so detection scans until the first decisive record. The guard already short-circuits once a platform is detected, so files that detect early are processed identically. The same piped input after the fix:

[2026-04-05T10:00:00] [user] fix the auth bug
---
[2026-04-05T10:00:05] [assistant] I'll investigate the auth module.

Verification

  • New regression test in tests/session-history-scripts.test.ts: prepends the 12-record metadata preamble to the existing Claude fixture and asserts user and assistant messages are still extracted. Fails on main, passes with the fix.
  • All four platform fixtures (claude, codex, cursor, pi) still detect and extract identically after the change, verified by piping each through the script directly.
  • One environment note: this machine has no python3 launcher, so the script tests were verified by piping through python directly; the bun-side tests exercise the same path on CI.
  • Full bun test baseline diff against main on this machine: zero new failures.

Scope notes

The issue's optional hardening (fail loudly when detection falls through to the default handler) is left out to keep this the minimal detection fix. Happy to follow up on it separately.

@LukeTheoJohnson LukeTheoJohnson marked this pull request as ready for review July 8, 2026 11:57
@tmchow tmchow merged commit 494c377 into EveryInc:main Jul 9, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 9, 2026
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.

extract-skeleton.py silently returns empty for all current Claude sessions (10-line detection cap)

2 participants