Skip to content

shelley/loop: report a tool panic as that call's error - #363

Open
AndrewFribush wants to merge 1 commit into
boldsoftware:mainfrom
AndrewFribush:fix/recover-tool-panic
Open

AndrewFribush wants to merge 1 commit into
boldsoftware:mainfrom
AndrewFribush:fix/recover-tool-panic

Conversation

@AndrewFribush

Copy link
Copy Markdown

executeToolCall runs each tool on its own goroutine with no recover, so a panic in any tool, including an MCP wrapper or a tool someone adds later, ends the server process and every conversation running in it, not just the turn that hit the bug.

Recover on that goroutine, log where it panicked, and send the panic back as the call's error. The model sees "tool NAME panicked (TYPE)", the rest of the batch runs, and the bug stays loud in the logs. A panic unwinds past the tool's secret redaction, so the result and the log carry the panic's type and call sites (function, file and line) but never its value or debug.Stack's raw frame arguments. Panics on goroutines a tool starts itself are not covered; those are the tool's to handle.

The new test runs a batch of a tool that indexes past a nil slice and a tool that succeeds, then a tool that panics with a string. Against the old code the first panic ends the test binary.

🤖 Generated with Claude Code

executeToolCall runs each tool on its own goroutine with no recover, so
a panic in any tool, including an MCP wrapper or a tool someone adds
later, ends the server process and every conversation running in it,
not just the turn that hit the bug.

Recover on that goroutine, log where it panicked, and send the panic
back as the call's error. The model sees "tool NAME panicked (TYPE)",
the rest of the batch runs, and the bug stays loud in the logs. A panic
unwinds past the tool's secret redaction, so the result and the log
carry the panic's type and call sites (function, file and line) but
never its value or debug.Stack's raw frame arguments. Panics on
goroutines a tool starts itself are not covered; those are the tool's
to handle.

The new test runs a batch of a tool that indexes past a nil slice and
a tool that succeeds, then a tool that panics with a string. Against
the old code the first panic ends the test binary.
@cla-bot cla-bot Bot added the cla-signed label Nov 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant