From c89370e66975b704c12238130f69733264820d4b Mon Sep 17 00:00:00 2001 From: zhouquan_wang Date: Fri, 12 Sep 2025 16:30:22 +0800 Subject: [PATCH 1/2] Add an interrupt error judgment function --- go/ai/tools.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/go/ai/tools.go b/go/ai/tools.go index 1f3198838d..4fb128dde9 100644 --- a/go/ai/tools.go +++ b/go/ai/tools.go @@ -19,6 +19,7 @@ package ai import ( "context" "encoding/json" + "errors" "fmt" "maps" @@ -81,6 +82,15 @@ func (e *toolInterruptError) Error() string { return "tool execution interrupted" } +// Determine whether the error is an interrupt error returned by the tool。 +func IsToolInterruptError(err error) (map[string]any, bool) { + var tie *toolInterruptError + if errors.As(err, &tie) { + return tie.Metadata, true + } + return nil, false +} + // InterruptOptions provides configuration for tool interruption. type InterruptOptions struct { Metadata map[string]any From d47c1daf9a45c6890b6cd80798129dba774ae9e0 Mon Sep 17 00:00:00 2001 From: wangzq <1437987627@qq.com> Date: Thu, 9 Oct 2025 10:12:33 +0800 Subject: [PATCH 2/2] Update go/ai/tools.go Co-authored-by: Alex Pascal --- go/ai/tools.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/go/ai/tools.go b/go/ai/tools.go index 4fb128dde9..febc27cfce 100644 --- a/go/ai/tools.go +++ b/go/ai/tools.go @@ -82,13 +82,13 @@ func (e *toolInterruptError) Error() string { return "tool execution interrupted" } -// Determine whether the error is an interrupt error returned by the tool。 -func IsToolInterruptError(err error) (map[string]any, bool) { +// IsToolInterruptError determines whether the error is an interrupt error returned by the tool. +func IsToolInterruptError(err error) (bool, map[string]any) { var tie *toolInterruptError if errors.As(err, &tie) { - return tie.Metadata, true + return true, tie.Metadata } - return nil, false + return false, nil } // InterruptOptions provides configuration for tool interruption.