fix(pi): restore Pi tool names on Claude responses - #253
Closed
gustavo-neiva wants to merge 1 commit into
Closed
gustavo-neiva wants to merge 1 commit into
gustavo-neiva wants to merge 1 commit into
Conversation
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.
Cause
Pi >=0.86 passes tools in transcript system messages, not
context.tools. The request converter already resolves those tools and exposes names likeBashto Claude, but the response stream still readscontext.tools(undefined), returningBashinstead of Pi’sbashand causingTool Bash not found.Fix
Resolve active tools from the normalized transcript on the response side, as the request converter already does, then map Claude Code names back to Pi names. A mocked SSE regression exercises the actual request and response path without credentials or API calls.
Validation
Bash), green after (bash).git diff --checkpass.This addresses the remaining response-side issue described in #244. #245 also proposes this fix but is currently conflicting with
main; this PR is scoped to the missing response-side change on currentmain.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Fixes Pi tool name round-tripping in Claude responses. The response stream now resolves active tools from the normalized transcript (as the request converter already does) instead of reading
context.tools, so Claude'sBashis mapped back to Pi'sbash. Previously, tool calls returnedBashand failed with "Tool Bash not found". Adds a mocked SSE regression test that exercises the real request/response path.Written for commit 020067a. Summary will update on new commits.
The PR appears safe to merge; request and response tool-name resolution are aligned and the regression path is covered.
Summary
This PR restores Pi-native tool names in streamed Claude responses by resolving active tools from the normalized transcript, matching request-side conversion.
context.toolsvalue with transcript-derived active tools.bashis sent asBashand restored tobash.Diagram
sequenceDiagram participant Pi participant Stream as Pi stream adapter participant Converter as Request converter participant Claude Pi->>Stream: Context with transcript toolsAdded: bash Stream->>Stream: Normalize transcript and resolve active tools Stream->>Converter: Build Anthropic request Converter->>Claude: Tool schema name: Bash Claude-->>Stream: SSE tool_use name: Bash Stream->>Stream: Map against active transcript tools Stream-->>Pi: Tool call name: bashReviews (1) · Last reviewed commit: "fix(pi): restore Pi tool names on Claude..."