Detailed changes
@@ -868,7 +868,7 @@ func (a *agent) prepareTools(tools []AgentTool, activeTools []string, disableAll
return preparedTools
}
-// validateAndRepairToolCall validates a tool call and attempts repair if validation fails
+// validateAndRepairToolCall validates a tool call and attempts repair if validation fails.
func (a *agent) validateAndRepairToolCall(ctx context.Context, toolCall ToolCallContent, availableTools []AgentTool, systemPrompt string, messages []Message, repairFunc RepairToolCallFunction) ToolCallContent {
if err := a.validateToolCall(toolCall, availableTools); err == nil {
return toolCall
@@ -896,7 +896,7 @@ func (a *agent) validateAndRepairToolCall(ctx context.Context, toolCall ToolCall
}
}
-// validateToolCall validates a tool call against available tools and their schemas
+// validateToolCall validates a tool call against available tools and their schemas.
func (a *agent) validateToolCall(toolCall ToolCallContent, availableTools []AgentTool) error {
var tool AgentTool
for _, t := range availableTools {
@@ -1009,7 +1009,7 @@ func WithRepairToolCall(fn RepairToolCallFunction) AgentOption {
}
}
-// processStepStream processes a single step's stream and returns the step result
+// processStepStream processes a single step's stream and returns the step result.
func (a *agent) processStepStream(ctx context.Context, stream StreamResponse, opts AgentStreamCall, _ []StepResult) (StepResult, bool, error) {
var stepContent []Content
var stepToolCalls []ToolCallContent
@@ -45,7 +45,7 @@ type ProviderOptions map[string]map[string]any
// - `tool-calls`: model triggered tool calls
// - `error`: model stopped because of an error
// - `other`: model stopped for other reasons
-// - `unknown`: the model has not transmitted a finish reason
+// - `unknown`: the model has not transmitted a finish reason.
type FinishReason string
const (
@@ -450,7 +450,7 @@ func (p ProviderDefinedTool) GetName() string {
return p.Name
}
-// Helpers
+// Helpers.
func NewUserMessage(prompt string, files ...FilePart) Message {
content := []MessagePart{
TextPart{
@@ -382,7 +382,7 @@ func toAnthropicTools(tools []ai.Tool, toolChoice *ai.ToolChoice, disableParalle
},
}
}
- return
+ return anthropicTools, anthropicToolChoice, warnings
}
switch *toolChoice {
@@ -401,7 +401,7 @@ func toAnthropicTools(tools []ai.Tool, toolChoice *ai.ToolChoice, disableParalle
},
}
case ai.ToolChoiceNone:
- return
+ return anthropicTools, anthropicToolChoice, warnings
default:
anthropicToolChoice = &anthropic.ToolChoiceUnionParam{
OfTool: &anthropic.ToolChoiceToolParam{
@@ -411,7 +411,7 @@ func toAnthropicTools(tools []ai.Tool, toolChoice *ai.ToolChoice, disableParalle
},
}
}
- return
+ return anthropicTools, anthropicToolChoice, warnings
}
func toAnthropicPrompt(prompt ai.Prompt, sendReasoningData bool) ([]anthropic.TextBlockParam, []anthropic.MessageParam, []ai.CallWarning) {
@@ -839,7 +839,7 @@ func toOpenAiTools(tools []ai.Tool, toolChoice *ai.ToolChoice) (openAiTools []op
})
}
if toolChoice == nil {
- return
+ return openAiTools, openAiToolChoice, warnings
}
switch *toolChoice {
@@ -861,7 +861,7 @@ func toOpenAiTools(tools []ai.Tool, toolChoice *ai.ToolChoice) (openAiTools []op
},
}
}
- return
+ return openAiTools, openAiToolChoice, warnings
}
func toOpenAiPrompt(prompt ai.Prompt) ([]openai.ChatCompletionMessageParamUnion, []ai.CallWarning) {
@@ -1129,7 +1129,7 @@ func toOpenAiPrompt(prompt ai.Prompt) ([]openai.ChatCompletionMessageParamUnion,
return messages, warnings
}
-// parseAnnotationsFromDelta parses annotations from the raw JSON of a delta
+// parseAnnotationsFromDelta parses annotations from the raw JSON of a delta.
func parseAnnotationsFromDelta(delta openai.ChatCompletionChunkChoiceDelta) []openai.ChatCompletionMessageAnnotation {
var annotations []openai.ChatCompletionMessageAnnotation