Skip to content

fix: emit success: false on ToolResultEvent for handled tool errors#933

Merged
sixlive merged 2 commits intoprism-php:mainfrom
chloe-pomegranate:fix/toolresultevent-success-false
Mar 9, 2026
Merged

fix: emit success: false on ToolResultEvent for handled tool errors#933
sixlive merged 2 commits intoprism-php:mainfrom
chloe-pomegranate:fix/toolresultevent-success-false

Conversation

@chloe-pomegranate
Copy link
Contributor

Description

  • Add a ToolError value object that Tool::handleToolException() returns instead of a plain string, allowing CallsTools::executeToolCall() to distinguish handled failures from genuine successes
  • ToolResultEvent now correctly emits success: false with the error field populated when the default or custom error handler catches an exception

Closes #909

Testing

  • Default error handler (validation error) produces ToolResultEvent(success: false)
  • Default error handler (runtime error) produces ToolResultEvent(success: false)
  • Custom error handler produces ToolResultEvent(success: false)
  • withoutErrorHandling() still throws and produces ToolResultEvent(success: false) via PrismException
  • Successful tool calls still produce ToolResultEvent(success: true)

@sixlive sixlive merged commit 387d48f into prism-php:main Mar 9, 2026
14 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.

Successful ToolResultEvents for failed Tool calls (which were handled by default Error Handler)

2 participants