Repository navigation
fix(pi): write slash commands as user text instead of orphan toolResults - #108
Merged
Merged
Conversation
A Claude Code slash command is canonically a Tool::Command ToolUse on a user turn plus its output as the paired ToolResult. The pi writer dropped user-side ToolUse blocks but still emitted the ToolResult as a pi toolResult (toolName "tool"), leaving a result no assistant toolCall opened. pi's provider refuses such a session on resume. Write the command as the text the user typed, and emit a toolResult only when its toolCall was written; any other result becomes user text. Campfire shares this writer and gets the same fix. Fixes #105
…command-pi # Conflicts: # tests/regression/main.rs
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.
Fixes #105
Problem
Claude Code stores a slash command such as
/renameas a tool use on a user turn, with its printed output as the paired tool result. When converting to pi,pi_payloads_fordropped the user-side tool use but still wrote the result as a pitoolResult(toolName: "tool"). No assistanttoolCallopens that id, so resuming the session in pi is refused by the provider (HTTP 400). Campfire shares this writer and had the same problem.Fix
/rename something).toolResultis emitted only when itstoolCallwas written; any other result becomes user text.docs/formats/pi.mddocuments the behaviour.The command and its output stay visible in the resumed session; only the structured command/result pairing (which pi can't represent on a user turn) is dropped. Assistant tool call/result pairs are unchanged.
Tests
tests/regression/pi_slash_command.rs: fails on main withorphan toolResult … no toolCall in the previous assistant message, passes on this branch.cargo fmt --check,cargo clippy --workspace --all-targets --all-features -D warnings, andcargo test --workspace --all-featuresall pass.Try it
Run
/rename xin Claude Code, thentxcript continue <id> --from claude_code --with pi, and resume in pi.