fix(proxy/ccr): self-heal dangling headroom_retrieve reference after … - #26
Merged
Merged
Conversation
…model switch
Switching models mid-session (/model in Claude Code) or restarting the
proxy rotated the model-scoped in-memory sticky session key, so the proxy
stopped injecting headroom_retrieve while the client transcript still
carried a tool_reference naming it — Anthropic 400'd every subsequent turn
("Tool reference 'headroom_retrieve' not found in available tools").
Injection now self-heals from the transcript: transcript_references_ccr_tool
scans about-to-forward messages for a bare headroom_retrieve in anthropic
tool_reference/tool_use blocks (one level of nesting) or an openai-chat
assistant.tool_calls entry, and a new transcript_requires_tool flag forces
(re-)injection through should_inject_ccr_tool and apply_session_sticky_ccr_tool
(decision inject_transcript_recovery), recording sticky state so subsequent
turns resume normal sticky replay. Exact bare-name match only, so a
client-owned mcp__headroom__headroom_retrieve never triggers proxy injection.
The openai /v1/responses path never proxy-injects the tool, so recovery is
N/A there.
PR governanceThis PR does not yet satisfy the required template fields:
Please update the PR body, or move the PR back to draft while it is still in progress. |
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.
…model switch
Switching models mid-session (/model in Claude Code) or restarting the proxy rotated the model-scoped in-memory sticky session key, so the proxy stopped injecting headroom_retrieve while the client transcript still carried a tool_reference naming it — Anthropic 400'd every subsequent turn ("Tool reference 'headroom_retrieve' not found in available tools").
Injection now self-heals from the transcript: transcript_references_ccr_tool scans about-to-forward messages for a bare headroom_retrieve in anthropic tool_reference/tool_use blocks (one level of nesting) or an openai-chat assistant.tool_calls entry, and a new transcript_requires_tool flag forces (re-)injection through should_inject_ccr_tool and apply_session_sticky_ccr_tool (decision inject_transcript_recovery), recording sticky state so subsequent turns resume normal sticky replay. Exact bare-name match only, so a client-owned mcp__headroom__headroom_retrieve never triggers proxy injection. The openai /v1/responses path never proxy-injects the tool, so recovery is N/A there.
Description
Closes #
Type of Change
Changes Made
Testing
pytest)ruff check .)mypy headroom)Test Output
Real Behavior Proof
Review Readiness
Checklist
CHANGELOG.md— it is generated by release-please from my Conventional Commit PR title (a CI guard enforces this)Screenshots (if applicable)
Add screenshots to help explain your changes.
Additional Notes