Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions go/ai/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package ai
import (
"context"
"encoding/json"
"errors"
"fmt"
"maps"

Expand Down Expand Up @@ -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
Expand Down