Repository navigation
Match session thinking and tool choice in handoff requests - #3
Merged
Merged
Conversation
Anthropic invalidates the cached message prefix when tool_choice or thinking parameters differ from the conversation's requests. Handoff notes sent toolChoice "none" without reasoning, so in the recorded sessions they read only 5-14% of their prompt from cache (3.96M of 20.5M tokens over 170 notes). A reply that calls a tool is now rejected, since tool use is no longer disabled.
2 of 4 tasks
HugoLopes45
added a commit
that referenced
this pull request
Oct 6, 2026
…security policy (#5) Every push to main ran the npm publication step. The merge of #3 tried to publish 0.2.0 and failed only because no trusted publisher exists yet. Merges now only prepare a version. Publication needs an explicit v* tag on main, successful CI on that commit, and owner approval of the npm environment. An existing npm version must come from the same commit. CI validates version changes and lockfile metadata, and runs weekly and against the latest Pi packages. The repository is public but had no contribution guide, security policy or issue template, so reports could leak session content in public issues.
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.
Why
Anthropic invalidates the cached message prefix when
tool_choiceor thinking parameters differ from earlier requests. Handoff note requests senttoolChoice: "none"and noreasoning, while session turns send no tool choice and the session thinking level. In the recorded sessions, 170 handoff notes read only 3.96M of 20.5M prompt tokens from cache (5-14% per note); the rest was re-billed at the input or cache-write rate.What
requestNotesends the session thinking level (pi.getThinkingLevel(),offmaps toundefinedas in Pi's agent loop) and no longer setstoolChoice.handoffNoterejects a reply that contains a tool call, because tool use is no longer disabled. Rejection falls back to Pi's summary.maxTokens, so a note can hit the length cap more often; that also falls back to Pi's summary. Models with budget-based thinking derive the budget frommaxTokensand can still miss the cache;claude-opus-5-5uses adaptive thinking.Checks
npm run checkpasses (91 tests). Both new tests failed before the fix for the intended reason.## UnreleasedinCHANGELOG.md.