style: gofmt

Formatting only (struct field alignment, import ordering) across the
files that didn't comply — no semantic changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Victor Hugo Vargas Servin 2026-07-12 16:14:15 -07:00
parent 2e23216932
commit 724a143f90
15 changed files with 88 additions and 90 deletions

View file

@ -96,10 +96,10 @@ func TestIntegration_AgentLoop_Generate(t *testing.T) {
}) })
loop := agent.New(agent.Config{ loop := agent.New(agent.Config{
LLM: client, LLM: client,
Persona: persona.DefaultPersona(), Persona: persona.DefaultPersona(),
Tools: registry, Tools: registry,
Sandbox: &mockSandbox{}, Sandbox: &mockSandbox{},
MaxIters: 3, MaxIters: 3,
}) })
@ -124,9 +124,9 @@ func TestIntegration_AgentLoop_Stream(t *testing.T) {
} }
loop := agent.New(agent.Config{ loop := agent.New(agent.Config{
LLM: client, LLM: client,
Persona: persona.DefaultPersona(), Persona: persona.DefaultPersona(),
Tools: tools.NewRegistry(), Tools: tools.NewRegistry(),
MaxIters: 3, MaxIters: 3,
}) })

View file

@ -28,8 +28,8 @@ func (m *mockLLM) Stream(ctx context.Context, req llm.CompletionRequest) iter.Se
return m.streamFunc(ctx, req) return m.streamFunc(ctx, req)
} }
func (m *mockLLM) Name() string { return "mock" } func (m *mockLLM) Name() string { return "mock" }
func (m *mockLLM) Capabilities() llm.ProviderCapabilities { return llm.ProviderCapabilities{} } func (m *mockLLM) Capabilities() llm.ProviderCapabilities { return llm.ProviderCapabilities{} }
type mockSandbox struct { type mockSandbox struct {
validateFunc func(tool tools.Tool, call llm.ToolCall) error validateFunc func(tool tools.Tool, call llm.ToolCall) error
@ -71,9 +71,9 @@ func TestNew_CustomMaxIters(t *testing.T) {
} }
loop := New(Config{ loop := New(Config{
LLM: mockClient, LLM: mockClient,
Persona: persona.DefaultPersona(), Persona: persona.DefaultPersona(),
Tools: tools.NewRegistry(), Tools: tools.NewRegistry(),
MaxIters: 10, MaxIters: 10,
}) })
@ -373,9 +373,9 @@ func TestRun_MaxIterations(t *testing.T) {
}) })
loop := New(Config{ loop := New(Config{
LLM: mockClient, LLM: mockClient,
Persona: persona.DefaultPersona(), Persona: persona.DefaultPersona(),
Tools: registry, Tools: registry,
MaxIters: 3, MaxIters: 3,
}) })
@ -706,9 +706,9 @@ func TestRun_Stream_MaxIterations(t *testing.T) {
}) })
loop := New(Config{ loop := New(Config{
LLM: mockClient, LLM: mockClient,
Persona: persona.DefaultPersona(), Persona: persona.DefaultPersona(),
Tools: registry, Tools: registry,
MaxIters: 1, MaxIters: 1,
}) })

View file

@ -7,34 +7,34 @@ import (
// ProviderConfig holds provider-specific settings. // ProviderConfig holds provider-specific settings.
type ProviderConfig struct { type ProviderConfig struct {
Type string `yaml:"type"` Type string `yaml:"type"`
Model string `yaml:"model"` Model string `yaml:"model"`
APIKey string `yaml:"api_key"` APIKey string `yaml:"api_key"`
BaseURL string `yaml:"base_url,omitempty"` BaseURL string `yaml:"base_url,omitempty"`
MaxTokens int `yaml:"max_tokens,omitempty"` MaxTokens int `yaml:"max_tokens,omitempty"`
Temperature float32 `yaml:"temperature,omitempty"` Temperature float32 `yaml:"temperature,omitempty"`
} }
// ToolPolicy controls which tools are available and their permissions. // ToolPolicy controls which tools are available and their permissions.
type ToolPolicy struct { type ToolPolicy struct {
DefaultPermission string `yaml:"default_permission"` DefaultPermission string `yaml:"default_permission"`
AllowList []string `yaml:"allow_list,omitempty"` AllowList []string `yaml:"allow_list,omitempty"`
DenyList []string `yaml:"deny_list,omitempty"` DenyList []string `yaml:"deny_list,omitempty"`
} }
// LoggingConfig controls logging output. // LoggingConfig controls logging output.
type LoggingConfig struct { type LoggingConfig struct {
Level string `yaml:"level"` Level string `yaml:"level"`
Format string `yaml:"format"` Format string `yaml:"format"`
Output string `yaml:"output"` Output string `yaml:"output"`
} }
// Config is the top-level configuration for the agent. // Config is the top-level configuration for the agent.
type Config struct { type Config struct {
Model string `yaml:"model"` Model string `yaml:"model"`
Provider ProviderConfig `yaml:"provider"` Provider ProviderConfig `yaml:"provider"`
Tools ToolPolicy `yaml:"tools"` Tools ToolPolicy `yaml:"tools"`
Logging LoggingConfig `yaml:"logging"` Logging LoggingConfig `yaml:"logging"`
} }
// Loader is responsible for loading configuration from various sources. // Loader is responsible for loading configuration from various sources.

View file

@ -10,9 +10,9 @@ import (
// MockLLMClient is a deterministic implementation of llm.LLMClient for testing. // MockLLMClient is a deterministic implementation of llm.LLMClient for testing.
type MockLLMClient struct { type MockLLMClient struct {
GenerateFunc func(ctx context.Context, req llm.CompletionRequest) (llm.CompletionResponse, error) GenerateFunc func(ctx context.Context, req llm.CompletionRequest) (llm.CompletionResponse, error)
StreamFunc func(ctx context.Context, req llm.CompletionRequest) iter.Seq2[llm.StreamChunk, error] StreamFunc func(ctx context.Context, req llm.CompletionRequest) iter.Seq2[llm.StreamChunk, error]
NameFunc func() string NameFunc func() string
CapabilitiesFunc func() llm.ProviderCapabilities CapabilitiesFunc func() llm.ProviderCapabilities
} }

View file

@ -167,7 +167,7 @@ func TestMockLLMClient_MatchResponse(t *testing.T) {
client := NewWithMatch([]MatchResponse{ client := NewWithMatch([]MatchResponse{
{Match: "hello", Response: "hi there!"}, {Match: "hello", Response: "hi there!"},
{Match: "world", Response: "earth"}, {Match: "world", Response: "earth"},
{Match: "*", Response: "default"}, {Match: "*", Response: "default"},
}) })
resp, _ := client.Generate(context.Background(), llm.CompletionRequest{ resp, _ := client.Generate(context.Background(), llm.CompletionRequest{

View file

@ -34,8 +34,8 @@ func TestClient_Generate(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(llamaChatResponse{ json.NewEncoder(w).Encode(llamaChatResponse{
ID: "llama-123", ID: "llama-123",
Model: "llama3", Model: "llama3",
Choices: []llamaChoice{ Choices: []llamaChoice{
{ {
Index: 0, Index: 0,
@ -189,8 +189,8 @@ func TestClient_Generate_ToolCall(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(llamaChatResponse{ json.NewEncoder(w).Encode(llamaChatResponse{
ID: "llama-tool-1", ID: "llama-tool-1",
Model: "llama3", Model: "llama3",
Choices: []llamaChoice{ Choices: []llamaChoice{
{ {
Index: 0, Index: 0,

View file

@ -33,8 +33,8 @@ func TestClient_Generate(t *testing.T) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(openaiChatResponse{ json.NewEncoder(w).Encode(openaiChatResponse{
ID: "test-123", ID: "test-123",
Model: "gpt-4", Model: "gpt-4",
Choices: []openaiChoice{ Choices: []openaiChoice{
{ {
Index: 0, Index: 0,
@ -55,8 +55,8 @@ func TestClient_Generate(t *testing.T) {
defer server.Close() defer server.Close()
client, err := New(Config{ client, err := New(Config{
APIKey: "test-key", APIKey: "test-key",
BaseURL: server.URL, BaseURL: server.URL,
}) })
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
@ -90,8 +90,8 @@ func TestClient_Generate_Error(t *testing.T) {
defer server.Close() defer server.Close()
client, err := New(Config{ client, err := New(Config{
APIKey: "bad-key", APIKey: "bad-key",
BaseURL: server.URL, BaseURL: server.URL,
}) })
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
@ -113,8 +113,8 @@ func TestClient_Stream(t *testing.T) {
defer server.Close() defer server.Close()
client, err := New(Config{ client, err := New(Config{
APIKey: "test-key", APIKey: "test-key",
BaseURL: server.URL + "/v1", BaseURL: server.URL + "/v1",
}) })
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)

View file

@ -10,18 +10,18 @@ import (
type Role string type Role string
const ( const (
RoleSystem Role = "system" RoleSystem Role = "system"
RoleUser Role = "user" RoleUser Role = "user"
RoleAssistant Role = "assistant" RoleAssistant Role = "assistant"
RoleTool Role = "tool" RoleTool Role = "tool"
) )
// Message is a single message in a conversation. // Message is a single message in a conversation.
type Message struct { type Message struct {
Role Role `json:"role"` Role Role `json:"role"`
Content string `json:"content"` Content string `json:"content"`
ToolCallID string `json:"tool_call_id,omitempty"` ToolCallID string `json:"tool_call_id,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
// ToolCalls records the calls an assistant message requested, so the // ToolCalls records the calls an assistant message requested, so the
// agent loop can replay them on the next request: without this, the // agent loop can replay them on the next request: without this, the
// conversation sent back to the model has tool-result messages with no // conversation sent back to the model has tool-result messages with no
@ -50,8 +50,8 @@ type TokenUsage struct {
type ToolChoice string type ToolChoice string
const ( const (
ToolChoiceAuto ToolChoice = "auto" ToolChoiceAuto ToolChoice = "auto"
ToolChoiceNone ToolChoice = "none" ToolChoiceNone ToolChoice = "none"
ToolChoiceRequired ToolChoice = "required" ToolChoiceRequired ToolChoice = "required"
) )
@ -73,14 +73,14 @@ func (t *ToolRef) MarshalJSON() ([]byte, error) {
// CompletionRequest is sent to an LLM provider. // CompletionRequest is sent to an LLM provider.
type CompletionRequest struct { type CompletionRequest struct {
Model string `json:"model"` Model string `json:"model"`
Messages []Message `json:"messages"` Messages []Message `json:"messages"`
Tools []json.RawMessage `json:"tools,omitempty"` Tools []json.RawMessage `json:"tools,omitempty"`
ToolChoice interface{} `json:"tool_choice,omitempty"` // ToolChoice, ToolRef, or null ToolChoice interface{} `json:"tool_choice,omitempty"` // ToolChoice, ToolRef, or null
Temperature *float32 `json:"temperature,omitempty"` Temperature *float32 `json:"temperature,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"` MaxTokens *int `json:"max_tokens,omitempty"`
Stop []string `json:"stop,omitempty"` Stop []string `json:"stop,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"` Metadata map[string]string `json:"metadata,omitempty"`
ChatTemplateKwargs map[string]any `json:"chat_template_kwargs,omitempty"` // model-specific chat template params, e.g. Qwen enable_thinking ChatTemplateKwargs map[string]any `json:"chat_template_kwargs,omitempty"` // model-specific chat template params, e.g. Qwen enable_thinking
} }
@ -98,9 +98,9 @@ type CompletionResponse struct {
// StopReason values. // StopReason values.
const ( const (
StopReasonEndTurn = "end_turn" StopReasonEndTurn = "end_turn"
StopReasonToolUse = "tool_use" StopReasonToolUse = "tool_use"
StopReasonMaxTokens = "max_tokens" StopReasonMaxTokens = "max_tokens"
StopReasonStopSeq = "stop_sequence" StopReasonStopSeq = "stop_sequence"
) )
// ToolCall represents a function invocation requested by the model. // ToolCall represents a function invocation requested by the model.

View file

@ -121,7 +121,7 @@ func TestToolCall_JSON(t *testing.T) {
func TestStreamChunk_JSON(t *testing.T) { func TestStreamChunk_JSON(t *testing.T) {
chunk := StreamChunk{ chunk := StreamChunk{
Delta: "hello", Delta: "hello",
ToolCalls: []ToolCall{}, ToolCalls: []ToolCall{},
} }
@ -139,7 +139,5 @@ func TestStreamChunk_JSON(t *testing.T) {
} }
} }
func float32Ptr(f float32) *float32 { return &f }
func float32Ptr(f float32) *float32 { return &f }
func intPtr(i int) *int { return &i } func intPtr(i int) *int { return &i }

View file

@ -18,7 +18,7 @@ type Persona struct {
Style string Style string
Language string Language string
Constraints []string Constraints []string
FewShot []llm.Message FewShot []llm.Message
} }
// Loader loads personas from files. // Loader loads personas from files.

View file

@ -224,13 +224,13 @@ func stringifyMap(m map[string]interface{}) map[string]string {
// chromaQueryResponse represents the structure of a ChromaDB query response. // chromaQueryResponse represents the structure of a ChromaDB query response.
type chromaQueryResponse struct { type chromaQueryResponse struct {
Names []string `json:"names"` Names []string `json:"names"`
Results []chromaQueryResults `json:"results"` Results []chromaQueryResults `json:"results"`
} }
type chromaQueryResults struct { type chromaQueryResults struct {
IDs [][]string `json:"ids"` IDs [][]string `json:"ids"`
Documents [][]string `json:"documents"` Documents [][]string `json:"documents"`
Distances [][]float64 `json:"distances"` Distances [][]float64 `json:"distances"`
Metadatas [][]map[string]interface{} `json:"metadatas"` Metadatas [][]map[string]interface{} `json:"metadatas"`
} }

View file

@ -54,7 +54,7 @@ func TestBackend_Search(t *testing.T) {
meta := []map[string]interface{}{{"key": "value"}} meta := []map[string]interface{}{{"key": "value"}}
metaNested := [][]map[string]interface{}{meta} metaNested := [][]map[string]interface{}{meta}
mockResponse := map[string]interface{}{ mockResponse := map[string]interface{}{
"names": []string{"rony-memory"}, "names": []string{"rony-memory"},
"results": []map[string]interface{}{ "results": []map[string]interface{}{
{ {
"ids": [][]string{{"test-id"}}, "ids": [][]string{{"test-id"}},

View file

@ -193,9 +193,9 @@ func TestMemory_Search_EmbeddingErrorFallsBackToLexicalSearch(t *testing.T) {
// mockBackend implements chroma.Backend for testing. // mockBackend implements chroma.Backend for testing.
type mockBackend struct { type mockBackend struct {
upsertFunc func(ctx context.Context, id string, vector []float32, content string, metadata map[string]string) error upsertFunc func(ctx context.Context, id string, vector []float32, content string, metadata map[string]string) error
searchFunc func(ctx context.Context, query string, queryVector []float32, topK int) ([]rag.SearchResult, error) searchFunc func(ctx context.Context, query string, queryVector []float32, topK int) ([]rag.SearchResult, error)
forgetAllFunc func(ctx context.Context) error forgetAllFunc func(ctx context.Context) error
} }
func (m *mockBackend) Upsert(ctx context.Context, id string, vector []float32, content string, metadata map[string]string) error { func (m *mockBackend) Upsert(ctx context.Context, id string, vector []float32, content string, metadata map[string]string) error {

View file

@ -6,9 +6,9 @@ import (
// registry is the default implementation of Registry. // registry is the default implementation of Registry.
type registry struct { type registry struct {
mu sync.RWMutex mu sync.RWMutex
tools map[string]Tool tools map[string]Tool
order []string order []string
} }
// NewRegistry returns a new empty registry. // NewRegistry returns a new empty registry.

View file

@ -45,10 +45,10 @@ type ToolHandler func(ctx context.Context, args json.RawMessage) (ToolResult, er
// ToolResult is returned by a ToolHandler. // ToolResult is returned by a ToolHandler.
type ToolResult struct { type ToolResult struct {
Content string Content string
IsError bool IsError bool
Metadata map[string]string Metadata map[string]string
Artifacts []Artifact Artifacts []Artifact
} }
// Artifact represents a file or data artifact produced by a tool. // Artifact represents a file or data artifact produced by a tool.
@ -60,8 +60,8 @@ type Artifact struct {
// ToolExample provides few-shot examples for the LLM to improve tool usage. // ToolExample provides few-shot examples for the LLM to improve tool usage.
type ToolExample struct { type ToolExample struct {
Input map[string]interface{} Input map[string]interface{}
Output string Output string
} }
// Registry manages tool registration and lookup. // Registry manages tool registration and lookup.