Repository navigation
feat(verifiers): always_on's judge reads a compaction as one, natively and from atif/1, and asks about context loss - #916
Open
earakely-scale wants to merge 8 commits into
Conversation
…y and from atif/1, and is asked about context loss A Claude Code compaction reached always_on's judge as two plain notes. Its compact_boundary and the summary after it are now one compaction note with its facts (who wrote the summary, its trigger, and the history's tokens before and after), the same from native stdout and from an atif/1 copy, whose profile 1.2 adds the compaction's tokens_before and tokens_after, written by Claude Code's adapter. A run whose trajectories hold a compaction gets the harness reading a labelled run gets: the harness-note lines, whose its summary's losses are, and, with a per-criterion format, the context-loss question, reported next to the score. A labelled run's prompt is unchanged, and a run without either gets none of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s its history fills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ces, which Bash's output cut doesn't Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… as one note with its facts from both paths Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale
marked this pull request as ready for review
November 24, 2026 19:35
… the copy, and a count must be a whole number The adapter made only a summary's first text block the compaction and wrote the rest as system steps, where native reads them as one note; it now joins them. The validator read a count's raw value only when it was already an int, so a string or a float the profile model takes passed; a count is now a whole number that isn't negative. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d atif/1's vocabularies, and a seeded test keeps them equal - The protocol exports is_token_count, which the builder, the validator, Claude Code's adapter and the judges' reader use in place of four copies of the check. - The judges' reader takes SUMMARY_WRITERS and COMPACTION_TRIGGERS from atif/1 rather than its own copies, and the OTel span's compaction checks who wrote its summary through compaction_facts, the one place that refuses an unknown writer. - The adapter holds a boundary it hasn't seen the summary of as one _Boundary, in place of three attributes and the entry's trigger and tokens. - test_claude_code_atif.py plays 200 seeded conversations that compact through the adapter and the native reader, and asserts both give a judge the same events and facts; it fails on the adapter before the multi-block fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…or has Its image installs any protocol at or above the floor, and the released protocol has no is_token_count, so importing it made the adapter fail to import and every Claude Code install built from the checkout fail. The adapter keeps its own count check and trigger names until its floor is raised. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The conflict was in always_on's context-loss gate: main holds it in a _ContextLoss each run sets (#905), and this branch asks a run whose trajectories hold a compaction too; the gate is main's holder, asked through _harness_read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Since #913, a Claude Code compaction reaches always_on's judge the same way natively and from atif/1, but only as two plain notes: the summary and the CLI's "Compacted". The judge isn't told:
It isn't asked whether a failed criterion traces to context the compaction lost. A run whose harness labels its own trace already gets all of this. This PR gives the same reading to any run whose trajectories hold a compaction, natively and from atif/1 alike.
What changes
One compaction note, from both paths (
judge_utils/turn_events.py)compact_boundaryand the summary after it are one compaction note with its facts:assistant, Claude Code's own model;manualorauto;atif_turn_eventsreads the same facts from the copy's compaction step, so both paths give the judge the same note.compaction_note). For example: "Compaction summary (written by the assistant's own model…; it replaces the older history the assistant sees; it was set off on request, such as by a command (manual); the history went from 28,634 tokens to 2,839)". It's followed by the summary.compaction_factsbuilds them for every reader: it takes atif/1'sSUMMARY_WRITERSandCOMPACTION_TRIGGERS, and it's the one place that refuses an unknown writer, an OTel span's included.The profile, 1.2 (
atif/profile.py,atif/PROFILE.md,atif/validator.py,atif/builder.py)tokens_beforeandtokens_after: the tokens of the history the agent sees just before and just after it, when the harness counts them.turn.compaction(..., tokens_before=..., tokens_after=...)and refuses anything that isn't a count of tokens. The validator'scompactionrule refuses a count that isn't a whole number or is negative.is_token_countis the one check of a count. The builder, the validator and the judges' reader use it.pre_tokensandpost_tokens.always_on's judge (
always_on_agent_verifier.py,always_on_staging.py)context_lossquestion, reported next to the score and never changing it.The recorder (
tst/manual/claude_code_atif/record.py) records a turn compacted partway through as its history fills: a smallCLAUDE_CODE_AUTO_COMPACT_WINDOW, and a file read in pieces with the Read tool, since Bash cuts a long output short. Its recording is the newautocompactedfixture, the first real auto-compaction the tests hold.Decided with Edgar
Choices to review
context_lossunsaid.not_said.CLAUDE_CODE_AUTO_COMPACT_WINDOW).Testing
"-1",-1.0,"300"andTruearecompactionfindings, and the profile model refuses2.5itself.systemstep./compactbetween turns, and the new auto-compaction partway through a turn.mainand on this branch: the nine atif/1 cases differ only in"version".task_step,agents,a2a_agentand the protocol suite pass (8,251), apart from this Mac's known failures. CI is green.auto, 58,741 tokens before and 32,484 after;/compactand an auto-compaction.env_vars).--keep), with the same judge model, about $1:verify(), three times withmainand three times with this branch, alternating.mainsamples.main's third sample of one verifier passed a criterion the other five failed, which is judge noise on the unchanged side. The overall score was 0.0 in all twelve, as in the run itself.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge.Summary
Gives native and ATIF compactions the same judge-facing note, including the writer, trigger, and available token counts.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR Native[Claude Code boundary and summary] --> Facts[Compaction facts and note] Native --> Adapter[ATIF adapter] Adapter --> Copy[ATIF compaction step] Copy --> Facts Facts --> Staging[Wake files and index] Staging --> Judge[Judge gets compaction guidance] Judge --> Result[Score with optional context-loss report]Reviews (7) · Last reviewed commit: "Merge main into fd-6942-y19" · Reviewed by Greptile