Repository navigation
feat(protocol): atif/1 profile 1.1 gives a compaction its step and a harness's own messages, which Claude Code's copy writes - #913
Merged
Conversation
…rness's own messages A compaction is the source: agent step of the model call that wrote its summary, carrying that call's metrics, its profile's compaction naming who wrote the summary (assistant or harness) and what set it off (manual or auto); a message the harness itself put in the conversation is a source: system step. The builder writes both (turn.compaction, turn.system_message), the validator holds a compaction to an agent step and a named writer, and reads a 1.0 document from an agent on an older SDK as its own: a minor only adds optional fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd the CLI's own messages system steps A compact_boundary and the summary after it are the step of the call that wrote the summary, profile compaction (assistant, its trigger), holding what the turn reported beyond its other steps, which the bridge's turn record now counts; the summary waits for that count, so a live reader never sees the step change. The CLI's own messages, a command's output say, are system steps. always_on's judge reads both as the notes a native turn gives, the judges' other atif/1 readers as the harness's rather than the agent's words, and a turn with no closing message ends "". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unts, and its copy matches native and its usage The compacted scenario re-recorded through the bridge's counted turn record: its copy's compaction step holds the summary call's tokens, so every turn's steps sum to its reported usage, and always_on's judge gets native's events on every turn; both pins come out. The adapter's held summary, a turn that counted less than its steps and one that never reported are unit-tested, and so is the bridge's turn record. A copy newer than the worker is now profile 1.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mpaction's step Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he one summary and every other call was counted Two compactions in one turn each took the whole remainder, so the copy's totals exceeded the turn's; and a call whose transcript record never came counted as nothing, so its tokens went to the summary. A compaction now takes the remainder only when it's the turn's one held summary and every other model call of the turn has its counts, and none otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt's own calls do The turn's tally keys a model by the name it was called as, which a gateway route prefixes, while every other step names it as the API answered. The compaction step now takes the root agent's latest model, and the turn's only when no root call named one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rn called The compaction took the root agent's last model across turns, so a /compact-only turn after a model change named the one before. Each turn's count now records how the model it was called as answered, and a compaction is named that way, or as called when no call of that model has answered yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale
deleted the
edgararakelyan/fd-6916-y17-atif-compaction
branch
November 24, 2026 18:32
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.
When Claude Code compacts its conversation (
/compact, or an auto-compaction), its atif/1 copy has lost two things since copies began:#890 pinned both gaps in the recorded tests. This PR closes them with a minor version of the atif/1 profile, 1.1. The tests now ask for full parity on every turn, and for the copy's steps to sum to every turn's reported usage.
What changes
The profile, 1.1 (
atif/profile.py,atif/PROFILE.md,atif/validator.py,atif/builder.py)source: agentstep: its message is the summary, and it carries that call's metrics.compactionfield names who wrote the summary (written_by:assistant, the agent's own model, orharness) and what set it off (trigger:manualorauto).turn.compaction(step=..., written_by=..., trigger=...).source: systemstep of its own, written byturn.system_message(text=...). ATIF's own source says whose it is, so it needs no new field. Nothing wrotesystemsteps before.agentstep that names who wrote its summary (the newcompactionrule), and checks both vocabularies.Claude Code (
agents/claude-code/claude_code_atif.py,a2a_server.py)compact_boundaryand the summary after it on stdout as the compaction step,written_by: assistant, with the boundary's trigger. The CLI's own messages, such as/compact's<local-command-stdout>Compacted</local-command-stdout>, becomesystemsteps.turnaux record now carries the turn's token counts beside its cost: uncached input apart from the cache, and the model when there was one.anthropic/claude-sonnet-5-5), while the steps name it as the API answered (claude-sonnet-5-5)./compact, nothing else follows in the turn, so live pages lose nothing. With an auto-compaction partway through a turn followed live, the steps after it wait too, and arrive when the turn ends. always_on doesn't follow live.The judges (
judge_utils/turn_events.py,judge_utils/atif_turns.py)atif_turn_eventsgives a compaction step and asystemstep as the notes a native Claude Code turn gives. A turn with no closing message ends with"", as the CLI's result gives it.compact_atif_trajectoryandtranscript_from_atifleave a compaction out of the agent's words and its final response. They already skippedsystemsteps.Decided with Edgar
agentstep of its summary call, carrying that call's metrics, rather than asystemstep, which can't hold metrics, or two steps.systemstep, with no new field.Choices to review
turn.compactionandturn.system_message. A floor must name a release on PyPI, and the first with them is the one that ships this PR.main's folder before that release installs an older protocol. There a compaction or a CLI message stops the conversation's atif/1 copy, and its later turns read as native./compactand always_on are unaffected.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=20didn't trigger it. The adapter's handling of one is unit-tested on records shaped like the recorded manual one, with steps before and after it.Testing
systemstep, and refuses a writer or trigger outside the vocabularies;test_claude_code_atif.py):/compact-only turn, and as called after a model change or when no call has answered; the test fails on both earlier versions of the fix.test_usage.py): theturnrecord's counts apart from the cache, the model when there's one, and nothing for a lower bound.compactedscenario, re-recorded through the image with the new bridge, about $0.30:task_step,agents,a2a_agentand the protocol suite pass. The failures are this Mac's known ones.systemsteps. Every task's document passes the validator, and it still catches its three planted bugs./compact, then a turn that reads what the summary kept. Each turn was a prompt step followed live with atif/1 prescribed, on the checkout's image with the branch's protocol.manual, with the summary call's tokens: 30,621 prompt (28,502 cached) and 856 completion.systemstep holds "Compacted", and the copy's token totals are present.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge with its documented rollout choices.Summary
Adds ATIF profile 1.1 support for compaction summaries, their usage, and messages written by the harness. Judges receive summaries and harness messages as notes.
Reviews (6) · Last reviewed commit: "fix(agents): a compaction after a model ..." · Reviewed by Greptile