chore: working tree reconciliation#42
Draft
marksverdhei wants to merge 6 commits into
Draft
Conversation
…ounts extract_text / extract_codex_text now take truncate=True|False. Scorers stay on truncate=True so large file contents don't dominate relevance scoring. turn_tokens switches to truncate=False so budget accounting matches what the API actually sees (tool_use inputs and function_call outputs are sent untruncated). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Two linked accounting bugs let compact.py claim it hit the budget while writing output many times over the requested size: 1. lib/selector.py: when the tail system turn was force-kept past the greedy pass, only used_tokens (local) got updated. result .scored_kept_tokens stayed low, so print_stats under-reported and the overshoot check in compact.py never tripped. The force-kept turn is always long (short tail turns are already in kept_indices), so its tokens now flow into scored_kept_tokens. 2. compact.py / compact_codex.py: nuclear_compact returns a fresh SelectionResult with empty dropped_turns. Swapping result destroyed the primary pass's dropped list before append_archive_jsonl ran, so a nuclear-fallback compaction lost the archive of discarded turns. Capture primary_dropped before the swap and restore it on the new result, so the archive always reflects what was actually dropped. Also brings compact_codex.py to parity with compact.py: adds the 10% budget padding (so we don't compact borderline sessions) and the same nuclear fallback path when primary scoring can't reach budget. Verified with 1.7M-byte session: tight budget (5k) correctly triggers nuclear, archive captures 6 primary-dropped turns, report and actual output agree. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
patcher.py: the patched cli.js silently downgraded PLUGIN_SETTING_METHOD=llama-embed (or any non-local method) to eitf, while the hook script accepted the same method name. Users saw different behavior on the two code paths with no signal. Now the patch throws SUPERCOMPACT_EITF:unsupported_method and the outer try/catch routes to the built-in LLM fallback, which is what the user would have gotten without the patch. supercompact-precompact.sh: backup rotation was a no-op because both pre-compact-full and pre-supercompact used fixed names, so cp overwrote the previous backup and ls | tail -n +4 had nothing to rotate. Each compaction destroyed the prior backup. Now names are timestamped with a shared stamp per run, so consecutive compactions accumulate and the keep-last-3 rotation actually prunes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Five entry points (compact.py, compact_codex.py, compact-session.sh, supercompact-precompact.sh, patched cli.js) default to 80,000 tokens except the cli.js patch, which uses max(40% × preCompactTokenCount, 40000). Spell this out so the percentage path isn't mistaken for a bug. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The nuclear pass was logging every truncation step (up to 8 lines per run). Replace with a single summary: input -> output tokens, final block size, and whether we fit the budget or gave up. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated hygiene sweep.