fix: do not synthesize exception for cancelled tools#2106
fix: do not synthesize exception for cancelled tools#2106zastrowm merged 1 commit intostrands-agents:mainfrom
Conversation
|
/strands review |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Assessment: Approve Clean, well-scoped bug fix that correctly addresses the over-eager exception synthesis introduced in #2046. The key insight — that cancellation is an intentional action, not a failure — is sound, and the Review Details
The approach of deriving span error status from |
|
Assessment: Approve Clean, well-scoped bug fix. Cancellation is correctly modeled as a deliberate action rather than a failure — Review Details
|
806391b to
fa87746
Compare
|
Assessment: Approve Well-scoped bug fix that correctly restores the cancellation contract broken by #2046. The separation of concerns is sound: Review Details
No new issues beyond what zastrowm's review already surfaced. |
Description
After #2046 , setting
cancel_toolon aBeforeToolCallEventnow populatesAfterToolCallEvent.exceptionwith a synthesized exception which cannot be overwritten, causing tool cancellations to appear as failures to downstream hooks.Cancellation is a deliberate action, not a failure.
AfterToolCallEvent.cancel_messagealready exists to identify cancelled tools; hooks can use it to distinguish cancellations from genuine exceptions without needing a fake exception object. Additionally, tool result status remains aserrorfor cancellations.Span observability is preserved:
StatusCode.ERRORis now set by inspectingtool_result["status"]directly rather than relying on a synthesized exception.Public API Changes
AfterToolCallEvent.exceptionis once againNonefor cancelled tools.cancel_messageremains the correct field to detect cancellations.Related Issues
#2046
Documentation PR
No documentation changes needed.
Type of Change
Bug fix
Testing
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.