Repository navigation
Hand every harness's over-limit delivery over as one pointer - #3743
Merged
Merged
Conversation
A delivery too large for a hook's context reached the agent two ways. Claude Code's and Pi's hooks (`hook_transport.render`) wrote a prose line naming `leaf delivery read <id>`, held to Claude Code's `HOOK_CONTEXT_LIMIT` with `<`. Codex's hook (`codex.offer_hook_delivery`) sent the `<leaf-delivery>` element the skill teaches, held to its own `HOOK_CONTEXT_BYTES` with `<=`. Each harness now states its limit as data, `Harness.hook_context_bytes`, and `Harness.fits_hook_context` is the one comparison; both hook paths hand an oversized delivery over as `delivery.delivery_pointer_prompt`. Both old constants and the prose pointer are gone. Behavior changes: - Claude Code's agent gets the `<leaf-delivery>` element in place of the prose line. Its limit is 9,990 bytes, the largest context measured to arrive whole, where 9,999 was allowed before. - Pi has no limit: its extension adds a hook's context at any size, so a large delivery now arrives inline and confirmed. A pointer still comes when the hook can't confirm the delivery. - Codex is unchanged. `event-batches.md`, "Handle the input", now says what a pointer looks like, and the harness references point there rather than restating how to read one. No protocol bump: hook output is not part of a vendored page. Scored with a new `document/oversized` delivery eval (a 10.5 KB comment, idle, Claude Code): base 3/3, candidate 3/3. Every run got a pointer, read the whole delivery and named the failing test from the end of the log. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # src/leaf/hook_transport.py
leaf-agent
previously approved these changes
Oct 23, 2026
leaf-agent
approved these changes
Oct 23, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 25, 2026
A pointer leaves its input unconfirmed until the reader runs `leaf delivery ack`, so each later Claude Code tool boundary of the same turn froze that input into a new delivery and pointed at it again under a new id: the model was handed the same input 2 to 4 times a turn, seen in every run of the `document/oversized` eval before and after #3743. **Pointer once per turn.** A tool boundary carries only new input. The hook now notes, per turn, each page it hands over by pointer (`hook_transport.POINTED`, a new state-home record at `sessions/<digest>.pointed`, starting at protocol 24 as a new record kind does), and a later PostToolBatch hands nothing from a page while its pointed input is unconfirmed. Once the reader acks, the page's later input follows at the next boundary. Stop and a prompt still hand unconfirmed input over again, as they do input Escape dropped, so an ignored pointer is not lost. The note names the turn's opening (`turn_opened`), so a prompt dropped and reopened into the same turn starts a fresh one and its tool boundaries point again. `note_pointer` writes under the session lock, only while the lifecycle it planned under is current, and takes that lock only until `CONFIRM_WITHIN`; a skipped note costs at most a repeated pointer, while waiting could push the hook past its harness's timeout and lose the pointer itself. **Inline handover of only recorded batches.** Previously, where a hook recorded some batches and one page refused (it changed hands, or its lock was held at the deadline), the whole delivery went as a pointer, but the recorded batches' opened pickups were confirmed by the turn's next hook though the model read none of them, so the cursor passed input nobody read. `receive_held` now returns the batches it recorded and the hook hands exactly those over inline. A refused batch's input stays pending for whoever holds its page. A pointer goes only when the delivery doesn't fit the harness's context or the hook recorded nothing. Behavior changes: - Input that arrives on a page between its pointer and the ack waits for the first tool boundary after the ack, instead of riding in a second pointer that repeats the first. - An agent no longer gets a pointer (and a `leaf delivery ack` refusal) for a page that changed hands mid-hook; that page's input waits for its owner. Tests in `tests/model/test_hooks.py` cover the once-per-turn pointer, the reopened prompt, and the partial-refusal and lock-deadline cases. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
A delivery too large for a hook's context reached the agent two ways. Claude Code's and Pi's hooks (
hook_transport.render) wrote a prose line namingleaf delivery read <id>, held to Claude Code'sHOOK_CONTEXT_LIMITwith<. Codex's hook (codex.offer_hook_delivery) sent the<leaf-delivery>element the skill teaches, held to its ownHOOK_CONTEXT_BYTESwith<=.Each harness now states its limit as data,
Harness.hook_context_bytes, andHarness.fits_hook_contextis the one comparison. Both hook paths hand an oversized delivery over asdelivery.delivery_pointer_prompt. Both old constants and the prose pointer are gone.Behavior changes:
<leaf-delivery>element in place of the prose line. Its limit is 9,990 bytes, the largest context measured to arrive whole, where 9,999 was allowed before.event-batches.md, "Handle the input", now says what a pointer looks like, and the harness references point there rather than restating how to read one. No protocol bump: hook output is not part of a vendored page.Eval
A new delivery-eval variant,
document/oversized, posts one 10.5 KB comment (a CI log whose single failure sits near the end) while the session is idle, so the wake turn's hook hands it over by pointer. Run on Claude Code, base 637d54d against the working tree,--repeat 3:<leaf-delivery>elementEvery run got a pointer, read the whole delivery, confirmed it and named the failing test. In 2 of 3 candidate runs the agent read
event-batches.mdbefore the delivery, which the skill asks for on every delivery and the prose pointer had let it skip; that extra read is most of the gap in answer time, within the runs' spread. Codex's text didn't change, and Pi has no eval target.Journeys on the working tree:
claude-code,pi,codex-app-serverandcodex-queueall passed.