@@ -3592,6 +3592,11 @@ func TestRunAppendsAbortedPlaceholderForUnexecutedToolCallsOnGuardStop(t *testin
35923592 if ! strings .Contains (strings .ToLower (placeholder ), "aborted" ) {
35933593 t .Fatalf ("expected the placeholder result to mark the call as aborted, got %q" , placeholder )
35943594 }
3595+ for _ , message := range result .Messages {
3596+ if message .ToolCallID == "flaky-2" && ! message .IsError {
3597+ t .Fatalf ("aborted placeholder must carry error status: %#v" , message )
3598+ }
3599+ }
35953600
35963601 // Every tool_use in the final assistant message must have a matching result.
35973602 for _ , message := range result .Messages {
@@ -3606,6 +3611,33 @@ func TestRunAppendsAbortedPlaceholderForUnexecutedToolCallsOnGuardStop(t *testin
36063611 }
36073612}
36083613
3614+ func TestRunCarriesToolErrorStatusIntoMessageHistory (t * testing.T ) {
3615+ registry := tools .NewRegistry ()
3616+ registry .Register (alwaysFailingTool {})
3617+ provider := & mockProvider {turns : [][]zeroruntime.StreamEvent {
3618+ {
3619+ {Type : zeroruntime .StreamEventToolCallStart , ToolCallID : "failed-call" , ToolName : "flaky" },
3620+ {Type : zeroruntime .StreamEventToolCallEnd , ToolCallID : "failed-call" },
3621+ {Type : zeroruntime .StreamEventDone },
3622+ },
3623+ {{Type : zeroruntime .StreamEventText , Content : "done" }, {Type : zeroruntime .StreamEventDone }},
3624+ }}
3625+
3626+ result , err := Run (context .Background (), "go" , provider , Options {Registry : registry })
3627+ if err != nil {
3628+ t .Fatal (err )
3629+ }
3630+ for _ , message := range result .Messages {
3631+ if message .ToolCallID == "failed-call" {
3632+ if ! message .IsError {
3633+ t .Fatalf ("failed tool result lost its structured status: %#v" , message )
3634+ }
3635+ return
3636+ }
3637+ }
3638+ t .Fatalf ("failed tool result missing from message history: %#v" , result .Messages )
3639+ }
3640+
36093641type secretEmittingTool struct { output string }
36103642
36113643func (t secretEmittingTool ) Name () string { return "leak" }
0 commit comments