Skip to content

fix(pi): write slash commands as user text instead of orphan toolResults - #108

Merged
NishantJoshi00 merged 2 commits into
mainfrom
fix/105-claude-slash-command-pi
Nov 18, 2026
Merged

NishantJoshi00 merged 2 commits into
mainfrom
fix/105-claude-slash-command-pi

Conversation

@NishantJoshi00

Copy link
Copy Markdown
Collaborator

Fixes #105

Problem

Claude Code stores a slash command such as /rename as a tool use on a user turn, with its printed output as the paired tool result. When converting to pi, pi_payloads_for dropped the user-side tool use but still wrote the result as a pi toolResult (toolName: "tool"). No assistant toolCall opens 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

  • A user-side slash command is written as the text that was typed (e.g. /rename something).
  • A toolResult is emitted only when its toolCall was written; any other result becomes user text.
  • docs/formats/pi.md documents 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

  • New tests/regression/pi_slash_command.rs: fails on main with orphan toolResult … no toolCall in the previous assistant message, passes on this branch.
  • cargo fmt --check, cargo clippy --workspace --all-targets --all-features -D warnings, and cargo test --workspace --all-features all pass.

Try it

Run /rename x in Claude Code, then txcript continue <id> --from claude_code --with pi, and resume in pi.

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
@NishantJoshi00
NishantJoshi00 merged commit c713dff into main Nov 18, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

claude_code → pi: a slash command becomes a toolResult with no tool call, and the copy is refused on resume

1 participant