Repository navigation
Guard against empty tool-result content on bare-command re-run - #34
Merged
yonilerner merged 1 commit intoAug 11, 2026
Merged
Conversation
Anthropic's API returns HTTP 400 with "tool_result: content cannot be empty if is_error is true" when a tool result block has isError=true and no text content. Because pi replays full conversation history on every turn, one such record permanently bricks the session — every subsequent prompt 400s until the JSONL is hand-edited. The trigger is the sandbox-escape re-run path: when the user presses Esc during an approved escape (e.g. a git push), runBareCommand SIGKILLs the process group, so the killed command writes nothing to either stream and resolves with exitCode=null, signal='SIGKILL'. The old code produced text: "" + isError: true — exactly the rejected shape. Fix: add bareExecResultToToolContent() in sandbox.ts that substitutes a descriptive placeholder whenever combined stdout+stderr is empty (naming the kill signal when one is present). Use it at the escape re-run site in pi-auto.ts.
mmarcuccio
marked this pull request as ready for review
August 5, 2026 16:33
yonilerner
enabled auto-merge (squash)
August 6, 2026 19:51
yonilerner
disabled auto-merge
August 10, 2026 22:25
yonilerner
enabled auto-merge (squash)
August 10, 2026 22:26
yonilerner
disabled auto-merge
August 11, 2026 19:31
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.
Anthropic returns HTTP 400 with
"tool_result: content cannot be empty if is_error is true"whenever a tool result block hasisError: trueand no text content. Because pi replays full history on every turn, one such record permanently bricks the session. The only recovery today is hand-editing the session JSONL.The trigger is the sandbox-escape re-run path. When the user presses Esc during an approved escape (e.g. a
git push),runBareCommandSIGKILLs the process group, so the killed command writes nothing to either stream and resolves withexitCode: null, signal: "SIGKILL". The old code atextensions/pi-auto.ts:436produced exactly the rejected shape:Changes
extensions/sandbox.ts— exportsbareExecResultToToolContent(result)which formats stdout/stderr as before but substitutes a descriptive placeholder (naming the kill signal when present) whenever combined output is emptyextensions/pi-auto.ts— uses the helper at the escape re-run sitetests/sandbox.test.ts— five new cases covering the normal path, empty+non-zero, empty+SIGKILL, and empty+success