agent

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package agent provides intelligent agent implementations for building AI-powered workflows.

The agent package implements various types of AI agents that can interact with Large Language Models (LLMs), use tools, and execute complex reasoning patterns. This package is designed to support multiple agent architectures including chat agents, ReAct (Reasoning and Acting) agents, and tool-using agents.

Agent Types

The package supports several agent types:

  • Chat Agent: Simple conversational agent for basic interactions
  • ReAct Agent: Implements the ReAct pattern for reasoning and acting
  • Tool Agent: Specialized agent that can use external tools
  • Custom Agent: Extensible agent type for custom implementations

Basic Usage

Creating a simple chat agent:

config := agent.Config{
	Name:        "ChatBot",
	Type:        "chat",
	Description: "A helpful chatbot",
	MaxSteps:    5,
	Temperature: 0.7,
}

agent, err := agent.NewAgent(config)
if err != nil {
	log.Fatal(err)
}

// Set LLM provider
provider, _ := llm.NewOpenAIProvider(llm.OpenAIConfig{
	APIKey: "your-api-key",
	Model:  "gpt-3.5-turbo",
})
agent.SetLLMProvider(provider)

// Execute the agent
ctx := context.Background()
state := core.NewBaseState()
state.Set("input", "Hello, how are you?")

result, err := agent.Execute(ctx, state)
if err != nil {
	log.Fatal(err)
}

fmt.Println(result.Get("response"))

ReAct Pattern

The ReAct (Reasoning and Acting) pattern allows agents to alternate between reasoning about a problem and taking actions to solve it:

config := agent.Config{
	Name:        "ReActAgent",
	Type:        "react",
	Description: "An agent that can reason and act",
	MaxSteps:    10,
	Temperature: 0.3,
}

agent, err := agent.NewAgent(config)
if err != nil {
	log.Fatal(err)
}

// Add tools for the agent to use
toolRegistry := tools.NewToolRegistry()
toolRegistry.Register("calculator", tools.NewCalculatorTool())
toolRegistry.Register("search", tools.NewWebSearchTool())
agent.SetToolRegistry(toolRegistry)

Tool Integration

Agents can use external tools to extend their capabilities:

// Create a tool-using agent
config := agent.Config{
	Name: "ToolAgent",
	Type: "tool",
}

agent, err := agent.NewAgent(config)
if err != nil {
	log.Fatal(err)
}

// Register tools
toolRegistry := tools.NewToolRegistry()
toolRegistry.Register("file_read", tools.NewFileReadTool())
toolRegistry.Register("http_request", tools.NewHTTPTool())
agent.SetToolRegistry(toolRegistry)

Multi-Agent Coordination

The package supports multi-agent systems where agents can coordinate and collaborate:

coordinator := agent.NewMultiAgentCoordinator(nil)

// Add agents to the coordinator
coordinator.RegisterAgent("researcher", researchAgent)
coordinator.RegisterAgent("writer", writerAgent)
coordinator.RegisterAgent("reviewer", reviewAgent)

// Execute coordinated workflow
result, err := coordinator.Execute(ctx, task)

Configuration Options

Agents can be configured with various options:

  • Name: Human-readable name for the agent
  • Type: Agent type (chat, react, tool, custom)
  • Description: Description of the agent's purpose
  • MaxSteps: Maximum number of execution steps
  • Temperature: LLM temperature for response generation
  • SystemPrompt: System prompt for the agent
  • Tools: List of available tools
  • Memory: Memory configuration for conversation history

Error Handling

The package provides comprehensive error handling:

result, err := agent.Execute(ctx, state)
if err != nil {
	switch {
	case errors.Is(err, agent.ErrMaxStepsExceeded):
		// Handle max steps exceeded
	case errors.Is(err, agent.ErrInvalidInput):
		// Handle invalid input
	case errors.Is(err, agent.ErrLLMProviderNotSet):
		// Handle missing LLM provider
	default:
		// Handle other errors
	}
}

Performance Considerations

For optimal performance:

  • Reuse agent instances when possible
  • Set appropriate MaxSteps to prevent infinite loops
  • Use connection pooling for LLM providers
  • Implement proper context cancellation
  • Monitor memory usage in long-running agents

Thread Safety

Agent instances are thread-safe and can be used concurrently. However, individual execution contexts should not be shared between goroutines.

Integration with Core Package

The agent package is tightly integrated with the core package for graph-based workflows:

// Use agent as a node in a graph
graph := core.NewGraph()
graph.AddNode("agent_node", func(ctx context.Context, state core.State) (core.State, error) {
	return agent.Execute(ctx, state)
})

For more examples and detailed usage, see the examples directory and the comprehensive test suite in agent_test.go.

Copyright (c) 2024 GoLangGraph Team

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAgent

func RegisterAgent(id string, definition AgentDefinition) error

RegisterAgent registers an agent definition globally

func RegisterAgentFactory

func RegisterAgentFactory(id string, factory AgentFactory) error

RegisterAgentFactory registers an agent factory globally

func ValidateDecision added in v0.2.0

func ValidateDecision(decision Decision, allowedActions []string) error

ValidateDecision validates a decision against allowed actions

func ValidateResumeCommand added in v0.2.0

func ValidateResumeCommand(resume *ResumeCommand, interrupt *InterruptData) error

ValidateResumeCommand validates a complete resume command against an interrupt

Types

type AdvancedAgentDefinition

type AdvancedAgentDefinition struct {
	*BaseAgentDefinition
	// contains filtered or unexported fields
}

AdvancedAgentDefinition provides additional customization capabilities

func NewAdvancedAgentDefinition

func NewAdvancedAgentDefinition(config *AgentConfig) *AdvancedAgentDefinition

NewAdvancedAgentDefinition creates a new advanced agent definition

func (*AdvancedAgentDefinition) BuildGraph

func (aad *AdvancedAgentDefinition) BuildGraph() (*core.Graph, error)

BuildGraph builds the custom graph

func (*AdvancedAgentDefinition) CreateAgent

func (aad *AdvancedAgentDefinition) CreateAgent() (Agent, error)

CreateAgent creates an advanced agent with custom components

func (*AdvancedAgentDefinition) GetCustomMiddleware

func (aad *AdvancedAgentDefinition) GetCustomMiddleware() []func(next func(*core.BaseState) (*core.BaseState, error)) func(*core.BaseState) (*core.BaseState, error)

GetCustomMiddleware returns custom middleware

func (*AdvancedAgentDefinition) GetCustomTools

func (aad *AdvancedAgentDefinition) GetCustomTools() []tools.Tool

GetCustomTools returns custom tools

func (*AdvancedAgentDefinition) WithCustomGraph

func (aad *AdvancedAgentDefinition) WithCustomGraph(graph *core.Graph) *AdvancedAgentDefinition

WithCustomGraph sets a custom graph

func (*AdvancedAgentDefinition) WithCustomMiddleware

func (aad *AdvancedAgentDefinition) WithCustomMiddleware(middleware ...func(next func(*core.BaseState) (*core.BaseState, error)) func(*core.BaseState) (*core.BaseState, error)) *AdvancedAgentDefinition

WithCustomMiddleware adds custom middleware

func (*AdvancedAgentDefinition) WithCustomTools

func (aad *AdvancedAgentDefinition) WithCustomTools(tools ...tools.Tool) *AdvancedAgentDefinition

WithCustomTools adds custom tools

func (*AdvancedAgentDefinition) WithGraphBuilder

func (aad *AdvancedAgentDefinition) WithGraphBuilder(builder func() (*core.Graph, error)) *AdvancedAgentDefinition

WithGraphBuilder sets a custom graph builder function

func (*AdvancedAgentDefinition) WithMiddlewareProvider

func (aad *AdvancedAgentDefinition) WithMiddlewareProvider(provider func() []func(next func(*core.BaseState) (*core.BaseState, error)) func(*core.BaseState) (*core.BaseState, error)) *AdvancedAgentDefinition

WithMiddlewareProvider sets a custom middleware provider function

func (*AdvancedAgentDefinition) WithToolsProvider

func (aad *AdvancedAgentDefinition) WithToolsProvider(provider func() []tools.Tool) *AdvancedAgentDefinition

WithToolsProvider sets a custom tools provider function

type Agent

type Agent interface {
	// Core execution
	Execute(ctx context.Context, input string) (*AgentExecution, error)

	// Configuration
	GetConfig() *AgentConfig
	UpdateConfig(config *AgentConfig)

	// State management
	GetGraph() *core.Graph
	// IsRunning returns true if the agent is currently executing
	IsRunning() bool

	// Conversation management
	GetConversation() []llm.Message
	ClearConversation()
	// SeedConversation restores prior ReAct messages (HITL mid-run resume).
	SeedConversation(messages []llm.Message)

	// History management
	GetExecutionHistory() []AgentExecution
	ClearHistory()

	// Metadata
	Name() string
}

Agent is the core interface for all AI agents in the system. It defines the standard behavior that any agent (Base, Deep, or Custom) must implement.

func CreateDeepAgent added in v0.2.0

func CreateDeepAgent(config *AgentConfig, llmManager *llm.ProviderManager, toolRegistry *tools.ToolRegistry) Agent

CreateDeepAgent creates a fully-configured Deep Agent with all middleware enabled. This provides a "batteries-included" experience similar to Python's create_deep_agent.

Features included: - TodoListMiddleware (Planning) - FilesystemMiddleware (Context/Memory) - SubAgentMiddleware (Delegation) - SummarizationMiddleware (Long context handling)

func CreateReActAgent added in v0.2.0

func CreateReActAgent(config *AgentConfig, llmManager *llm.ProviderManager, toolRegistry *tools.ToolRegistry) Agent

CreateReActAgent creates a standard ReAct agent without deep middleware. Useful for simpler tasks or as a base for custom agents.

func NewQuickAgent added in v0.2.0

func NewQuickAgent(name string) (Agent, error)

NewQuickAgent creates a QuickStart agent with default Ollama LLM

func NewSimpleAgent added in v0.2.0

func NewSimpleAgent(name, model, provider string) (Agent, error)

NewSimpleAgent creates a simple chat agent with minimal configuration

type AgentConfig

type AgentConfig struct {
	ID              string         `json:"id"`
	Name            string         `json:"name"`
	Type            AgentType      `json:"type"`
	Model           string         `json:"model"`
	Provider        string         `json:"provider"`
	SystemPrompt    string         `json:"system_prompt"`
	Temperature     float64        `json:"temperature"`
	MaxTokens       int            `json:"max_tokens"`
	MaxIterations   int            `json:"max_iterations"`
	Tools           []string       `json:"tools"`
	EnableStreaming bool           `json:"enable_streaming"`
	StreamingMode   llm.StreamMode `json:"streaming_mode,omitempty"`
	// EarlyExit cancels remaining stream tokens once a complete JSON/tool-call
	// is formed. Nil disables token-stream early-exit (multipass JSON exit still applies).
	EarlyExit    llm.EarlyExitFunc        `json:"-"`
	Timeout      time.Duration            `json:"timeout"`
	Metadata     map[string]interface{}   `json:"metadata"`
	Middleware   []Middleware             `json:"-"`
	InterruptOn  []string                 `json:"interrupt_on"`
	Checkpointer persistence.Checkpointer `json:"-"`
}

AgentConfig represents agent configuration

func DefaultAgentConfig

func DefaultAgentConfig() *AgentConfig

DefaultAgentConfig returns default agent configuration

func (*AgentConfig) Validate

func (config *AgentConfig) Validate() error

Validate validates the agent configuration

func (*AgentConfig) ValidateAndSanitize

func (config *AgentConfig) ValidateAndSanitize() error

ValidateAndSanitize validates the agent configuration and sanitizes problematic values

type AgentDefinition

type AgentDefinition interface {
	// GetConfig returns the base configuration for the agent
	GetConfig() *AgentConfig

	// Initialize sets up the agent with the provided managers
	Initialize(llmManager *llm.ProviderManager, toolRegistry *tools.ToolRegistry) error

	// CreateAgent creates and returns the configured agent instance
	CreateAgent() (Agent, error)

	// GetMetadata returns additional metadata about the agent
	GetMetadata() map[string]interface{}

	// Validate validates the agent definition
	Validate() error
}

AgentDefinition represents a programmatic agent definition

type AgentDefinitionBuilder

type AgentDefinitionBuilder struct {
	// contains filtered or unexported fields
}

AgentDefinitionBuilder provides a fluent interface for building agent definitions

func NewAgentDefinitionBuilder

func NewAgentDefinitionBuilder() *AgentDefinitionBuilder

NewAgentDefinitionBuilder creates a new agent definition builder

func (*AgentDefinitionBuilder) Build

Build creates the agent definition

func (*AgentDefinitionBuilder) WithMaxTokens

func (adb *AgentDefinitionBuilder) WithMaxTokens(maxTokens int) *AgentDefinitionBuilder

WithMaxTokens sets the max tokens

func (*AgentDefinitionBuilder) WithMetadata

func (adb *AgentDefinitionBuilder) WithMetadata(key string, value interface{}) *AgentDefinitionBuilder

WithMetadata sets metadata

func (*AgentDefinitionBuilder) WithModel

func (adb *AgentDefinitionBuilder) WithModel(model string) *AgentDefinitionBuilder

WithModel sets the LLM model

func (*AgentDefinitionBuilder) WithName

WithName sets the agent name

func (*AgentDefinitionBuilder) WithProvider

func (adb *AgentDefinitionBuilder) WithProvider(provider string) *AgentDefinitionBuilder

WithProvider sets the LLM provider

func (*AgentDefinitionBuilder) WithSystemPrompt

func (adb *AgentDefinitionBuilder) WithSystemPrompt(prompt string) *AgentDefinitionBuilder

WithSystemPrompt sets the system prompt

func (*AgentDefinitionBuilder) WithTemperature

func (adb *AgentDefinitionBuilder) WithTemperature(temperature float64) *AgentDefinitionBuilder

WithTemperature sets the temperature

func (*AgentDefinitionBuilder) WithTools

func (adb *AgentDefinitionBuilder) WithTools(tools ...string) *AgentDefinitionBuilder

WithTools sets the tools

func (*AgentDefinitionBuilder) WithType

func (adb *AgentDefinitionBuilder) WithType(agentType AgentType) *AgentDefinitionBuilder

WithType sets the agent type

type AgentExecution

type AgentExecution struct {
	ID               string
	Input            string
	Output           interface{}
	Success          bool
	StartTime        time.Time
	EndTime          time.Time
	Duration         time.Duration
	Status           string // "running", "completed", "failed", "interrupted"
	Steps            []AgentStep
	ToolCalls        []llm.ToolCall
	Error            error
	Metadata         map[string]interface{}
	StructuredOutput interface{}
	ExecutionPath    []string
}

AgentExecution tracks the execution state of an agent

type AgentFactory

type AgentFactory func() AgentDefinition

AgentFactory is a function type for creating agent definitions

type AgentInfo

type AgentInfo struct {
	ID       string                 `json:"id"`
	Source   AgentSource            `json:"source"`
	Config   *AgentConfig           `json:"config,omitempty"`
	Metadata map[string]interface{} `json:"metadata"`
}

AgentInfo provides information about a registered agent

type AgentMetrics

type AgentMetrics struct {
	RequestCount   int64         `json:"request_count"`
	ErrorCount     int64         `json:"error_count"`
	AverageLatency time.Duration `json:"average_latency"`
	LastRequest    time.Time     `json:"last_request"`
	TotalLatency   time.Duration `json:"total_latency"`
}

AgentMetrics tracks metrics for individual agents

type AgentRegistry

type AgentRegistry struct {
	// contains filtered or unexported fields
}

AgentRegistry manages programmatically defined agents

func GetGlobalRegistry

func GetGlobalRegistry() *AgentRegistry

GetGlobalRegistry returns the global agent registry

func NewAgentRegistry

func NewAgentRegistry() *AgentRegistry

NewAgentRegistry creates a new agent registry

func (*AgentRegistry) CreateAgentFromDefinition

func (ar *AgentRegistry) CreateAgentFromDefinition(id string, llmManager *llm.ProviderManager, toolRegistry *tools.ToolRegistry) (Agent, error)

CreateAgentFromDefinition creates an agent from a registered definition

func (*AgentRegistry) CreateAgentFromFactory

func (ar *AgentRegistry) CreateAgentFromFactory(id string, llmManager *llm.ProviderManager, toolRegistry *tools.ToolRegistry) (Agent, error)

CreateAgentFromFactory creates an agent using a registered factory

func (*AgentRegistry) GetAgentInfo

func (ar *AgentRegistry) GetAgentInfo() []AgentInfo

GetAgentInfo returns information about all registered agents

func (*AgentRegistry) GetDefinition

func (ar *AgentRegistry) GetDefinition(id string) (AgentDefinition, bool)

GetDefinition retrieves an agent definition by ID

func (*AgentRegistry) GetMetadata

func (ar *AgentRegistry) GetMetadata() map[string]map[string]interface{}

GetMetadata returns metadata for all registered agents

func (*AgentRegistry) ListDefinitions

func (ar *AgentRegistry) ListDefinitions() []string

ListDefinitions returns all registered agent definition IDs

func (*AgentRegistry) ListFactories

func (ar *AgentRegistry) ListFactories() []string

ListFactories returns all registered agent factory IDs

func (*AgentRegistry) LoadFromPlugin

func (ar *AgentRegistry) LoadFromPlugin(pluginPath string) error

LoadFromPlugin loads agent definitions from a Go plugin

func (*AgentRegistry) RegisterDefinition

func (ar *AgentRegistry) RegisterDefinition(id string, definition AgentDefinition) error

RegisterDefinition registers an agent definition with a unique ID

func (*AgentRegistry) RegisterFactory

func (ar *AgentRegistry) RegisterFactory(id string, factory AgentFactory) error

RegisterFactory registers an agent factory function

type AgentSource

type AgentSource string

AgentSource represents where an agent definition comes from

const (
	SourceConfig     AgentSource = "config"
	SourceDefinition AgentSource = "definition"
	SourceFactory    AgentSource = "factory"
	SourcePlugin     AgentSource = "plugin"
)

type AgentState

type AgentState struct {
	ID           string                 `json:"id"`
	Status       string                 `json:"status"` // "starting", "running", "stopping", "stopped", "error"
	StartedAt    time.Time              `json:"started_at"`
	UpdatedAt    time.Time              `json:"updated_at"`
	RequestCount int64                  `json:"request_count"`
	ErrorCount   int64                  `json:"error_count"`
	LastRequest  time.Time              `json:"last_request"`
	LastError    string                 `json:"last_error"`
	HealthStatus string                 `json:"health_status"`
	Metadata     map[string]interface{} `json:"metadata"`
}

AgentState tracks the state of individual agents

type AgentStep added in v0.2.0

type AgentStep struct {
	NodeID    string
	Timestamp time.Time
	Input     map[string]interface{}
	Output    map[string]interface{}
	Error     error
}

AgentStep represents a single step in the agent's execution

type AgentType

type AgentType string

AgentType represents the type of agent

const (
	AgentTypeReAct AgentType = "react"
	AgentTypeChat  AgentType = "chat"
	AgentTypeTool  AgentType = "tool"
)

type AlertRule

type AlertRule struct {
	Name        string            `json:"name" yaml:"name"`
	Description string            `json:"description" yaml:"description"`
	Metric      string            `json:"metric" yaml:"metric"`
	Condition   string            `json:"condition" yaml:"condition"`
	Threshold   float64           `json:"threshold" yaml:"threshold"`
	Duration    time.Duration     `json:"duration" yaml:"duration"`
	Labels      map[string]string `json:"labels" yaml:"labels"`
	Annotations map[string]string `json:"annotations" yaml:"annotations"`
}

AlertRule defines alert rule

type AlertingConfig

type AlertingConfig struct {
	Enabled  bool            `json:"enabled" yaml:"enabled"`
	Webhooks []WebhookConfig `json:"webhooks" yaml:"webhooks"`
	Email    *EmailConfig    `json:"email" yaml:"email"`
	Slack    *SlackConfig    `json:"slack" yaml:"slack"`
	Rules    []AlertRule     `json:"rules" yaml:"rules"`
}

AlertingConfig defines alerting configuration

type AuthConfig

type AuthConfig struct {
	Type     string                 `json:"type" yaml:"type"` // "jwt", "oauth", "basic", "apikey"
	Config   map[string]interface{} `json:"config" yaml:"config"`
	Enabled  bool                   `json:"enabled" yaml:"enabled"`
	Required bool                   `json:"required" yaml:"required"`
}

AuthConfig defines authentication configuration

type AuthzConfig

type AuthzConfig struct {
	Type    string                 `json:"type" yaml:"type"` // "rbac", "acl", "policy"
	Config  map[string]interface{} `json:"config" yaml:"config"`
	Enabled bool                   `json:"enabled" yaml:"enabled"`
}

AuthzConfig defines authorization configuration

type BaseAgent added in v0.2.0

type BaseAgent struct {
	// contains filtered or unexported fields
}

BaseAgent represents the standard AI agent implementation

func NewAgent

func NewAgent(config *AgentConfig, llmManager *llm.ProviderManager, toolRegistry *tools.ToolRegistry) *BaseAgent

NewAgent creates a new base agent

func (*BaseAgent) ClearConversation added in v0.2.0

func (a *BaseAgent) ClearConversation()

ClearConversation clears the agent's conversation history

func (*BaseAgent) ClearHistory added in v0.2.0

func (a *BaseAgent) ClearHistory()

ClearHistory clears the agent's execution history

func (*BaseAgent) DisableStreaming added in v0.2.0

func (a *BaseAgent) DisableStreaming() error

DisableStreaming disables streaming mode for the agent

func (*BaseAgent) EnableStreaming added in v0.2.0

func (a *BaseAgent) EnableStreaming() error

EnableStreaming enables streaming mode for the agent

func (*BaseAgent) Execute added in v0.2.0

func (a *BaseAgent) Execute(ctx context.Context, input string) (*AgentExecution, error)

Execute executes the agent with the given input

func (*BaseAgent) ExecuteThread added in v0.2.0

func (a *BaseAgent) ExecuteThread(ctx context.Context, threadID string, input string) (*AgentExecution, error)

ExecuteThread executes the agent with the given input in a specific thread

func (*BaseAgent) GetConfig added in v0.2.0

func (a *BaseAgent) GetConfig() *AgentConfig

GetConfig returns the agent's configuration

func (*BaseAgent) GetConversation added in v0.2.0

func (a *BaseAgent) GetConversation() []llm.Message

GetConversation returns the agent's conversation history

func (*BaseAgent) GetExecutionHistory added in v0.2.0

func (a *BaseAgent) GetExecutionHistory() []AgentExecution

GetExecutionHistory returns the agent's execution history

func (*BaseAgent) GetGraph added in v0.2.0

func (a *BaseAgent) GetGraph() *core.Graph

GetGraph returns the agent's execution graph

func (*BaseAgent) GetStreamingMode added in v0.2.0

func (a *BaseAgent) GetStreamingMode() llm.StreamMode

GetStreamingMode returns the current streaming mode

func (*BaseAgent) IsRunning added in v0.2.0

func (a *BaseAgent) IsRunning() bool

IsRunning returns true if the agent is currently executing

func (*BaseAgent) IsStreamingEnabled added in v0.2.0

func (a *BaseAgent) IsStreamingEnabled() bool

IsStreamingEnabled returns whether streaming is enabled

func (*BaseAgent) Name added in v0.2.0

func (a *BaseAgent) Name() string

Name returns the name of the agent

func (*BaseAgent) SeedConversation added in v0.2.0

func (a *BaseAgent) SeedConversation(messages []llm.Message)

SeedConversation restores prior ReAct messages for mid-run HITL resume.

func (*BaseAgent) SeedResumeState added in v0.2.0

func (a *BaseAgent) SeedResumeState(messages []llm.Message, iteration int, pending []llm.ToolCall)

SeedResumeState restores conversation, iteration, and pending tool calls.

func (*BaseAgent) SetGraph added in v0.2.0

func (a *BaseAgent) SetGraph(graph *core.Graph)

SetGraph sets the agent's execution graph

func (*BaseAgent) SetStreamingMode added in v0.2.0

func (a *BaseAgent) SetStreamingMode(mode llm.StreamMode) error

SetStreamingMode sets the streaming mode for the agent

func (*BaseAgent) UpdateConfig added in v0.2.0

func (a *BaseAgent) UpdateConfig(config *AgentConfig)

UpdateConfig updates the agent configuration

type BaseAgentDefinition

type BaseAgentDefinition struct {
	// contains filtered or unexported fields
}

BaseAgentDefinition provides a base implementation of AgentDefinition

func NewBaseAgentDefinition

func NewBaseAgentDefinition(config *AgentConfig) *BaseAgentDefinition

NewBaseAgentDefinition creates a new base agent definition

func (*BaseAgentDefinition) CreateAgent

func (bad *BaseAgentDefinition) CreateAgent() (Agent, error)

CreateAgent creates a standard agent instance

func (*BaseAgentDefinition) GetConfig

func (bad *BaseAgentDefinition) GetConfig() *AgentConfig

GetConfig returns the agent configuration

func (*BaseAgentDefinition) GetMetadata

func (bad *BaseAgentDefinition) GetMetadata() map[string]interface{}

GetMetadata returns agent metadata

func (*BaseAgentDefinition) Initialize

func (bad *BaseAgentDefinition) Initialize(llmManager *llm.ProviderManager, toolRegistry *tools.ToolRegistry) error

Initialize sets up the agent with managers

func (*BaseAgentDefinition) SetMetadata

func (bad *BaseAgentDefinition) SetMetadata(key string, value interface{})

SetMetadata sets a metadata value

func (*BaseAgentDefinition) Validate

func (bad *BaseAgentDefinition) Validate() error

Validate validates the agent definition

type BaseMiddleware added in v0.2.0

type BaseMiddleware struct{}

BaseMiddleware provides default no-op implementations

func (*BaseMiddleware) AfterRun added in v0.2.0

func (m *BaseMiddleware) AfterRun(ctx context.Context, agent *BaseAgent, result *AgentExecution) (*AgentExecution, error)

func (*BaseMiddleware) BeforeRun added in v0.2.0

func (m *BaseMiddleware) BeforeRun(ctx context.Context, agent *BaseAgent, input string) (string, error)

func (*BaseMiddleware) Name added in v0.2.0

func (m *BaseMiddleware) Name() string

type CORSConfig

type CORSConfig struct {
	Enabled          bool     `json:"enabled" yaml:"enabled"`
	AllowedOrigins   []string `json:"allowed_origins" yaml:"allowed_origins"`
	AllowedMethods   []string `json:"allowed_methods" yaml:"allowed_methods"`
	AllowedHeaders   []string `json:"allowed_headers" yaml:"allowed_headers"`
	ExposedHeaders   []string `json:"exposed_headers" yaml:"exposed_headers"`
	AllowCredentials bool     `json:"allow_credentials" yaml:"allow_credentials"`
	MaxAge           int      `json:"max_age" yaml:"max_age"`
}

CORSConfig defines CORS configuration

type CacheConfig

type CacheConfig struct {
	Type       string        `json:"type" yaml:"type"`
	Host       string        `json:"host" yaml:"host"`
	Port       int           `json:"port" yaml:"port"`
	Password   string        `json:"password" yaml:"password"`
	Database   int           `json:"database" yaml:"database"`
	TTL        time.Duration `json:"ttl" yaml:"ttl"`
	MaxRetries int           `json:"max_retries" yaml:"max_retries"`
}

CacheConfig defines cache configuration

type Command added in v0.2.0

type Command struct {
	// Update contains state changes to apply
	Update map[string]interface{}
	// Resume contains instructions to resume from an interrupt
	Resume *ResumeCommand
	// Goto specifies a specific node to navigate to
	Goto string
}

Command represents a control flow instruction for LangGraph-style operations This enables tools to return state updates, navigation commands, or resume instructions

type CustomAgentDefinition

type CustomAgentDefinition interface {
	AgentDefinition

	// BuildGraph allows custom graph construction
	BuildGraph() (*core.Graph, error)

	// GetCustomTools returns custom tools specific to this agent
	GetCustomTools() []tools.Tool

	// GetCustomMiddleware returns custom middleware for this agent
	GetCustomMiddleware() []func(next func(*core.BaseState) (*core.BaseState, error)) func(*core.BaseState) (*core.BaseState, error)
}

CustomAgentDefinition allows for completely custom agent creation

type CustomMetricConfig

type CustomMetricConfig struct {
	Name        string `json:"name" yaml:"name"`
	Type        string `json:"type" yaml:"type"`
	Query       string `json:"query" yaml:"query"`
	TargetValue string `json:"target_value" yaml:"target_value"`
	Resource    string `json:"resource" yaml:"resource"`
}

CustomMetricConfig defines custom metric for scaling

type DNSConfig

type DNSConfig struct {
	Policy      string   `json:"policy" yaml:"policy"`
	Nameservers []string `json:"nameservers" yaml:"nameservers"`
	Searches    []string `json:"searches" yaml:"searches"`
	Options     []string `json:"options" yaml:"options"`
}

DNSConfig defines DNS configuration

type DatabaseConfig

type DatabaseConfig struct {
	Type         string        `json:"type" yaml:"type"`
	Host         string        `json:"host" yaml:"host"`
	Port         int           `json:"port" yaml:"port"`
	Database     string        `json:"database" yaml:"database"`
	Username     string        `json:"username" yaml:"username"`
	Password     string        `json:"password" yaml:"password"`
	SSLMode      string        `json:"ssl_mode" yaml:"ssl_mode"`
	MaxConns     int           `json:"max_conns" yaml:"max_conns"`
	MaxIdleConns int           `json:"max_idle_conns" yaml:"max_idle_conns"`
	MaxLifetime  time.Duration `json:"max_lifetime" yaml:"max_lifetime"`
}

DatabaseConfig defines database configuration

type Decision added in v0.2.0

type Decision struct {
	// Type is one of: "approve", "edit", "reject", "response"
	Type string
	// Args contains additional arguments for edit/response types
	// For "edit": {"action": "tool_name", "args": {...}}
	// For "response": {"response": "text to return as tool result"}
	Args map[string]interface{}
}

Decision represents a human decision on an interrupted tool action

type DeploymentConfig

type DeploymentConfig struct {
	Type        string                 `json:"type" yaml:"type"` // "docker", "kubernetes", "serverless"
	Environment string                 `json:"environment" yaml:"environment"`
	Replicas    int                    `json:"replicas" yaml:"replicas"`
	Resources   *ResourceConfig        `json:"resources" yaml:"resources"`
	Networking  *NetworkingConfig      `json:"networking" yaml:"networking"`
	Scaling     *ScalingConfig         `json:"scaling" yaml:"scaling"`
	HealthCheck *HealthCheckConfig     `json:"health_check" yaml:"health_check"`
	Secrets     map[string]string      `json:"secrets" yaml:"secrets"`
	ConfigMaps  map[string]string      `json:"config_maps" yaml:"config_maps"`
	Volumes     []VolumeConfig         `json:"volumes" yaml:"volumes"`
	Metadata    map[string]interface{} `json:"metadata" yaml:"metadata"`
}

DeploymentConfig defines deployment configuration

type DeploymentState

type DeploymentState struct {
	Status      string                 `json:"status"`
	StartedAt   time.Time              `json:"started_at"`
	UpdatedAt   time.Time              `json:"updated_at"`
	AgentStates map[string]*AgentState `json:"agent_states"`
	ErrorCount  int                    `json:"error_count"`
	LastError   string                 `json:"last_error"`
	Metadata    map[string]interface{} `json:"metadata"`
}

DeploymentState tracks the deployment state of agents

type EmailConfig

type EmailConfig struct {
	SMTP     *SMTPConfig `json:"smtp" yaml:"smtp"`
	From     string      `json:"from" yaml:"from"`
	To       []string    `json:"to" yaml:"to"`
	Subject  string      `json:"subject" yaml:"subject"`
	Template string      `json:"template" yaml:"template"`
}

EmailConfig defines email configuration

type EncryptionAtRestConfig

type EncryptionAtRestConfig struct {
	Enabled   bool   `json:"enabled" yaml:"enabled"`
	Algorithm string `json:"algorithm" yaml:"algorithm"`
	KeyID     string `json:"key_id" yaml:"key_id"`
	Provider  string `json:"provider" yaml:"provider"`
}

EncryptionAtRestConfig defines encryption at rest configuration

type EncryptionConfig

type EncryptionConfig struct {
	AtRest    *EncryptionAtRestConfig    `json:"at_rest" yaml:"at_rest"`
	InTransit *EncryptionInTransitConfig `json:"in_transit" yaml:"in_transit"`
}

EncryptionConfig defines encryption configuration

type EncryptionInTransitConfig

type EncryptionInTransitConfig struct {
	Enabled  bool     `json:"enabled" yaml:"enabled"`
	MinTLS   string   `json:"min_tls" yaml:"min_tls"`
	Ciphers  []string `json:"ciphers" yaml:"ciphers"`
	CertFile string   `json:"cert_file" yaml:"cert_file"`
	KeyFile  string   `json:"key_file" yaml:"key_file"`
}

EncryptionInTransitConfig defines encryption in transit configuration

type ErrorHandlerFunc added in v0.2.0

type ErrorHandlerFunc func(error) string

ErrorHandlerFunc defines how tool errors are handled

type ExtendedAgentConfig

type ExtendedAgentConfig struct {
	*AgentConfig
	Path         string             `json:"path" yaml:"path"`
	Port         int                `json:"port" yaml:"port"`
	Host         string             `json:"host" yaml:"host"`
	Subdomain    string             `json:"subdomain" yaml:"subdomain"`
	Schema       *SchemaConfig      `json:"schema" yaml:"schema"`
	Middleware   []MiddlewareConfig `json:"middleware" yaml:"middleware"`
	Resources    *ResourceConfig    `json:"resources" yaml:"resources"`
	Scaling      *ScalingConfig     `json:"scaling" yaml:"scaling"`
	Environment  map[string]string  `json:"environment" yaml:"environment"`
	Secrets      map[string]string  `json:"secrets" yaml:"secrets"`
	ConfigMaps   map[string]string  `json:"config_maps" yaml:"config_maps"`
	Volumes      []VolumeConfig     `json:"volumes" yaml:"volumes"`
	Dependencies []string           `json:"dependencies" yaml:"dependencies"`
	Priority     int                `json:"priority" yaml:"priority"`
	Labels       map[string]string  `json:"labels" yaml:"labels"`
	Annotations  map[string]string  `json:"annotations" yaml:"annotations"`
	Disabled     bool               `json:"disabled" yaml:"disabled"`
}

ExtendedAgentConfig extends AgentConfig with additional deployment-specific fields

type FileBasedAgentLoader

type FileBasedAgentLoader struct {
	// contains filtered or unexported fields
}

FileBasedAgentLoader loads agent definitions from Go files

func NewFileBasedAgentLoader

func NewFileBasedAgentLoader(registry *AgentRegistry) *FileBasedAgentLoader

NewFileBasedAgentLoader creates a new file-based agent loader

func (*FileBasedAgentLoader) LoadFromDirectory

func (fbal *FileBasedAgentLoader) LoadFromDirectory(directory string) error

LoadFromDirectory loads all agent definitions from a directory

type FilesystemMiddleware added in v0.2.0

type FilesystemMiddleware struct {
	BaseMiddleware
	// contains filtered or unexported fields
}

FilesystemMiddleware implements virtual filesystem capabilities with pluggable backends

func NewFilesystemMiddleware added in v0.2.0

func NewFilesystemMiddleware(backend backends.BackendProtocol) *FilesystemMiddleware

NewFilesystemMiddleware creates filesystem middleware with a backend For backwards compatibility, if backend is nil, uses in-memory storage

func (*FilesystemMiddleware) BeforeRun added in v0.2.0

func (m *FilesystemMiddleware) BeforeRun(ctx context.Context, agent *BaseAgent, input string) (string, error)

func (*FilesystemMiddleware) Name added in v0.2.0

func (m *FilesystemMiddleware) Name() string

type HTTPHeader

type HTTPHeader struct {
	Name  string `json:"name" yaml:"name"`
	Value string `json:"value" yaml:"value"`
}

HTTPHeader defines HTTP header for health checks

type HealthCheckConfig

type HealthCheckConfig struct {
	Enabled             bool                          `json:"enabled" yaml:"enabled"`
	Path                string                        `json:"path" yaml:"path"`
	Port                int                           `json:"port" yaml:"port"`
	InitialDelaySeconds int                           `json:"initial_delay_seconds" yaml:"initial_delay_seconds"`
	PeriodSeconds       int                           `json:"period_seconds" yaml:"period_seconds"`
	TimeoutSeconds      int                           `json:"timeout_seconds" yaml:"timeout_seconds"`
	SuccessThreshold    int                           `json:"success_threshold" yaml:"success_threshold"`
	FailureThreshold    int                           `json:"failure_threshold" yaml:"failure_threshold"`
	HTTPHeaders         []HTTPHeader                  `json:"http_headers" yaml:"http_headers"`
	AgentSpecific       map[string]*HealthCheckConfig `json:"agent_specific" yaml:"agent_specific"`
}

HealthCheckConfig defines health check configuration

type HealthChecker

type HealthChecker struct {
	AgentID          string
	Config           *HealthCheckConfig
	LastCheck        time.Time
	Status           string
	ConsecutiveFails int
	Logger           *logrus.Logger
}

HealthChecker performs health checks for agents

type IngressConfig

type IngressConfig struct {
	Enabled     bool              `json:"enabled" yaml:"enabled"`
	ClassName   string            `json:"class_name" yaml:"class_name"`
	Hosts       []string          `json:"hosts" yaml:"hosts"`
	Rules       []IngressRule     `json:"rules" yaml:"rules"`
	TLS         []IngressTLS      `json:"tls" yaml:"tls"`
	Annotations map[string]string `json:"annotations" yaml:"annotations"`
}

IngressConfig defines ingress configuration

type IngressPath

type IngressPath struct {
	Path        string `json:"path" yaml:"path"`
	PathType    string `json:"path_type" yaml:"path_type"`
	ServiceName string `json:"service_name" yaml:"service_name"`
	ServicePort int    `json:"service_port" yaml:"service_port"`
	AgentID     string `json:"agent_id" yaml:"agent_id"`
}

IngressPath defines ingress path

type IngressRule

type IngressRule struct {
	Host    string        `json:"host" yaml:"host"`
	Paths   []IngressPath `json:"paths" yaml:"paths"`
	AgentID string        `json:"agent_id" yaml:"agent_id"`
}

IngressRule defines ingress rule

type IngressTLS

type IngressTLS struct {
	Hosts      []string `json:"hosts" yaml:"hosts"`
	SecretName string   `json:"secret_name" yaml:"secret_name"`
}

IngressTLS defines TLS configuration for ingress

type InterruptData added in v0.2.0

type InterruptData struct {
	// ToolCalls are the pending tool calls awaiting approval
	ToolCalls []llm.ToolCall
	// AllowedActions maps tool names to allowed decision types
	// e.g., {"delete_file": ["approve", "reject"], "send_email": ["approve", "edit", "reject"]}
	AllowedActions map[string][]string
}

InterruptData holds information about an interrupted execution Used for Human-in-the-Loop (HITL) workflows

type InterruptManager added in v0.2.0

type InterruptManager struct {
	// contains filtered or unexported fields
}

InterruptManager handles interrupt lifecycle for HITL workflows

func NewInterruptManager added in v0.2.0

func NewInterruptManager() *InterruptManager

NewInterruptManager creates a new interrupt manager

func (*InterruptManager) Clear added in v0.2.0

func (im *InterruptManager) Clear()

Clear removes all pending interrupts

func (*InterruptManager) GetPending added in v0.2.0

func (im *InterruptManager) GetPending(interruptID string) (*InterruptData, error)

GetPending retrieves a pending interrupt by ID

func (*InterruptManager) Interrupt added in v0.2.0

func (im *InterruptManager) Interrupt(
	toolCalls []llm.ToolCall,
	allowedActions map[string][]string,
) (string, *InterruptData, error)

Interrupt creates a new interrupt for the given tool calls Returns the interrupt ID and the InterruptData

func (*InterruptManager) ListPending added in v0.2.0

func (im *InterruptManager) ListPending() []string

ListPending returns all pending interrupt IDs

func (*InterruptManager) Resume added in v0.2.0

func (im *InterruptManager) Resume(
	interruptID string,
	decisions []Decision,
) (*ResumeCommand, error)

Resume processes a resume command for an interrupted execution Validates decisions and removes the interrupt from pending list

func (*InterruptManager) SetInterruptCallback added in v0.2.0

func (im *InterruptManager) SetInterruptCallback(callback func(*InterruptData))

SetInterruptCallback sets a callback function called when interrupts occur

type LLMProviderConfig

type LLMProviderConfig struct {
	Type       string                 `json:"type" yaml:"type"`
	APIKey     string                 `json:"api_key" yaml:"api_key"`
	Endpoint   string                 `json:"endpoint" yaml:"endpoint"`
	Model      string                 `json:"model" yaml:"model"`
	Config     map[string]interface{} `json:"config" yaml:"config"`
	Timeout    time.Duration          `json:"timeout" yaml:"timeout"`
	MaxRetries int                    `json:"max_retries" yaml:"max_retries"`
}

LLMProviderConfig defines LLM provider configuration

type LoggingConfig

type LoggingConfig struct {
	Level      string            `json:"level" yaml:"level"`
	Format     string            `json:"format" yaml:"format"`
	Output     []string          `json:"output" yaml:"output"`
	Structured bool              `json:"structured" yaml:"structured"`
	Fields     map[string]string `json:"fields" yaml:"fields"`
}

LoggingConfig defines logging configuration

type MetricsConfig

type MetricsConfig struct {
	Enabled   bool   `json:"enabled" yaml:"enabled"`
	Path      string `json:"path" yaml:"path"`
	Port      int    `json:"port" yaml:"port"`
	Namespace string `json:"namespace" yaml:"namespace"`
	Subsystem string `json:"subsystem" yaml:"subsystem"`
}

MetricsConfig defines metrics configuration

type Middleware added in v0.2.0

type Middleware interface {
	// Name returns the name of the middleware
	Name() string
	// BeforeRun is called before the agent execution starts
	BeforeRun(ctx context.Context, agent *BaseAgent, input string) (string, error)
	// AfterRun is called after the agent execution finishes
	AfterRun(ctx context.Context, agent *BaseAgent, result *AgentExecution) (*AgentExecution, error)
}

Middleware defines the interface for agent middleware

type MiddlewareConfig

type MiddlewareConfig struct {
	Type    string                 `json:"type" yaml:"type"`
	Config  map[string]interface{} `json:"config" yaml:"config"`
	Enabled bool                   `json:"enabled" yaml:"enabled"`
}

MiddlewareConfig defines middleware configuration

type MiddlewareFunc

type MiddlewareFunc func(next http.Handler) http.Handler

MiddlewareFunc defines middleware function signature

type MonitoringConfig

type MonitoringConfig struct {
	Enabled  bool            `json:"enabled" yaml:"enabled"`
	Metrics  *MetricsConfig  `json:"metrics" yaml:"metrics"`
	Tracing  *TracingConfig  `json:"tracing" yaml:"tracing"`
	Alerting *AlertingConfig `json:"alerting" yaml:"alerting"`
}

MonitoringConfig defines monitoring configuration

type MultiAgentConfig

type MultiAgentConfig struct {
	Name        string                  `json:"name" yaml:"name"`
	Version     string                  `json:"version" yaml:"version"`
	Description string                  `json:"description" yaml:"description"`
	Agents      map[string]*AgentConfig `json:"agents" yaml:"agents"`
	Routing     *RoutingConfig          `json:"routing" yaml:"routing"`
	Deployment  *DeploymentConfig       `json:"deployment" yaml:"deployment"`
	Shared      *SharedConfig           `json:"shared" yaml:"shared"`
	Metadata    map[string]interface{}  `json:"metadata" yaml:"metadata"`
}

MultiAgentConfig represents a configuration for multiple agents

func DefaultMultiAgentConfig

func DefaultMultiAgentConfig() *MultiAgentConfig

DefaultMultiAgentConfig returns default multi-agent configuration

func LoadMultiAgentConfigFromFile

func LoadMultiAgentConfigFromFile(filename string) (*MultiAgentConfig, error)

LoadConfigFromFile loads multi-agent configuration from a file

func (*MultiAgentConfig) GetAgentByPath

func (mac *MultiAgentConfig) GetAgentByPath(path string) (string, bool)

GetAgentByPath returns the agent ID for a given path

func (*MultiAgentConfig) GetAgentPaths

func (mac *MultiAgentConfig) GetAgentPaths() map[string][]string

GetAgentPaths returns all paths for each agent

func (*MultiAgentConfig) GetAgentPort

func (mac *MultiAgentConfig) GetAgentPort(agentID string) int

GetAgentPort returns the port for a specific agent

func (*MultiAgentConfig) GetEnabledAgents

func (mac *MultiAgentConfig) GetEnabledAgents() map[string]*AgentConfig

GetEnabledAgents returns only enabled agents

func (*MultiAgentConfig) ListAgentIDs

func (mac *MultiAgentConfig) ListAgentIDs() []string

ListAgentIDs returns all agent IDs

func (*MultiAgentConfig) Validate

func (mac *MultiAgentConfig) Validate() error

Validate validates the multi-agent configuration

type MultiAgentCoordinator

type MultiAgentCoordinator struct {
	// contains filtered or unexported fields
}

MultiAgentCoordinator manages multiple agents for complex workflows

func NewMultiAgentCoordinator

func NewMultiAgentCoordinator(config *MultiAgentConfig) *MultiAgentCoordinator

NewMultiAgentCoordinator creates a new coordinator If config is nil, creates a default configuration

func (*MultiAgentCoordinator) ExecuteParallel

func (mac *MultiAgentCoordinator) ExecuteParallel(ctx context.Context, agentIDs []string, input string) (map[string]AgentExecution, error)

ExecuteParallel executes agents in parallel with the same input

func (*MultiAgentCoordinator) ExecuteSequential

func (mac *MultiAgentCoordinator) ExecuteSequential(ctx context.Context, agentIDs []string, initialInput string) ([]AgentExecution, error)

ExecuteSequential executes agents sequentially, passing output to the next

func (*MultiAgentCoordinator) GetAgent

func (mac *MultiAgentCoordinator) GetAgent(id string) (Agent, bool)

GetAgent retrieves an agent by ID

func (*MultiAgentCoordinator) ListAgents

func (mac *MultiAgentCoordinator) ListAgents() []string

ListAgents returns all agent IDs

func (*MultiAgentCoordinator) RegisterAgent added in v0.2.0

func (mac *MultiAgentCoordinator) RegisterAgent(id string, agent Agent)

RegisterAgent adds an agent to the coordinator

func (*MultiAgentCoordinator) RemoveAgent

func (mac *MultiAgentCoordinator) RemoveAgent(id string)

RemoveAgent removes an agent from the coordinator

type MultiAgentManager

type MultiAgentManager struct {
	// contains filtered or unexported fields
}

MultiAgentManager manages multiple agents with routing and deployment capabilities

func NewMultiAgentManager

func NewMultiAgentManager(config *MultiAgentConfig, llmManager *llm.ProviderManager, toolRegistry *tools.ToolRegistry) (*MultiAgentManager, error)

NewMultiAgentManager creates a new multi-agent manager

func (*MultiAgentManager) GetConfig

func (mam *MultiAgentManager) GetConfig() *MultiAgentConfig

GetConfig returns the multi-agent configuration

func (*MultiAgentManager) GetDeploymentState

func (mam *MultiAgentManager) GetDeploymentState() *DeploymentState

GetDeploymentState returns current deployment state

func (*MultiAgentManager) GetMetrics

func (mam *MultiAgentManager) GetMetrics() *MultiAgentMetrics

GetMetrics returns current metrics

func (*MultiAgentManager) GetRouter

func (mam *MultiAgentManager) GetRouter() *mux.Router

GetRouter returns the HTTP router

func (*MultiAgentManager) Start

func (mam *MultiAgentManager) Start(ctx context.Context) error

Start starts the multi-agent manager

func (*MultiAgentManager) Stop

func (mam *MultiAgentManager) Stop(ctx context.Context) error

Stop stops the multi-agent manager

type MultiAgentMetrics

type MultiAgentMetrics struct {
	TotalRequests  int64                    `json:"total_requests"`
	TotalErrors    int64                    `json:"total_errors"`
	AgentMetrics   map[string]*AgentMetrics `json:"agent_metrics"`
	RoutingMetrics *RoutingMetrics          `json:"routing_metrics"`
	LastUpdated    time.Time                `json:"last_updated"`
	// contains filtered or unexported fields
}

MultiAgentMetrics tracks metrics for multi-agent system

type NetworkingConfig

type NetworkingConfig struct {
	Type        string            `json:"type" yaml:"type"` // "ClusterIP", "NodePort", "LoadBalancer"
	Ports       []PortConfig      `json:"ports" yaml:"ports"`
	Ingress     *IngressConfig    `json:"ingress" yaml:"ingress"`
	DNS         *DNSConfig        `json:"dns" yaml:"dns"`
	TLS         *TLSConfig        `json:"tls" yaml:"tls"`
	Proxy       *ProxyConfig      `json:"proxy" yaml:"proxy"`
	Annotations map[string]string `json:"annotations" yaml:"annotations"`
}

NetworkingConfig defines networking configuration

type PortConfig

type PortConfig struct {
	Name       string `json:"name" yaml:"name"`
	Port       int    `json:"port" yaml:"port"`
	TargetPort int    `json:"target_port" yaml:"target_port"`
	Protocol   string `json:"protocol" yaml:"protocol"`
	AgentID    string `json:"agent_id" yaml:"agent_id"`
}

PortConfig defines port configuration

type PropertyDefinition

type PropertyDefinition struct {
	Type        string                         `json:"type" yaml:"type"`
	Description string                         `json:"description" yaml:"description"`
	Properties  map[string]*PropertyDefinition `json:"properties" yaml:"properties"`
	Items       *PropertyDefinition            `json:"items" yaml:"items"`
	Required    []string                       `json:"required" yaml:"required"`
	MinLength   int                            `json:"min_length" yaml:"min_length"`
	MaxLength   int                            `json:"max_length" yaml:"max_length"`
	Minimum     float64                        `json:"minimum" yaml:"minimum"`
	Maximum     float64                        `json:"maximum" yaml:"maximum"`
	Pattern     string                         `json:"pattern" yaml:"pattern"`
	Format      string                         `json:"format" yaml:"format"`
	Enum        []interface{}                  `json:"enum" yaml:"enum"`
	Default     interface{}                    `json:"default" yaml:"default"`
	Example     interface{}                    `json:"example" yaml:"example"`
}

PropertyDefinition defines property definition

type ProxyConfig

type ProxyConfig struct {
	Enabled      bool              `json:"enabled" yaml:"enabled"`
	Type         string            `json:"type" yaml:"type"` // "http", "socks5"
	URL          string            `json:"url" yaml:"url"`
	Headers      map[string]string `json:"headers" yaml:"headers"`
	Timeout      time.Duration     `json:"timeout" yaml:"timeout"`
	Retries      int               `json:"retries" yaml:"retries"`
	MaxIdleConns int               `json:"max_idle_conns" yaml:"max_idle_conns"`
}

ProxyConfig defines proxy configuration

type RateLimit

type RateLimit struct {
	Requests  int           `json:"requests" yaml:"requests"`
	Period    time.Duration `json:"period" yaml:"period"`
	Burst     int           `json:"burst" yaml:"burst"`
	SkipPaths []string      `json:"skip_paths" yaml:"skip_paths"`
}

RateLimit defines rate limit configuration

type RateLimitConfig

type RateLimitConfig struct {
	Enabled    bool                  `json:"enabled" yaml:"enabled"`
	Global     *RateLimit            `json:"global" yaml:"global"`
	PerAgent   map[string]*RateLimit `json:"per_agent" yaml:"per_agent"`
	PerUser    *RateLimit            `json:"per_user" yaml:"per_user"`
	PerIP      *RateLimit            `json:"per_ip" yaml:"per_ip"`
	BurstLimit int                   `json:"burst_limit" yaml:"burst_limit"`
	WindowSize time.Duration         `json:"window_size" yaml:"window_size"`
}

RateLimitConfig defines rate limiting configuration

type ResourceConfig

type ResourceConfig struct {
	CPU      string `json:"cpu" yaml:"cpu"`
	Memory   string `json:"memory" yaml:"memory"`
	Storage  string `json:"storage" yaml:"storage"`
	GPU      string `json:"gpu" yaml:"gpu"`
	Requests *struct {
		CPU     string `json:"cpu" yaml:"cpu"`
		Memory  string `json:"memory" yaml:"memory"`
		Storage string `json:"storage" yaml:"storage"`
	} `json:"requests" yaml:"requests"`
	Limits *struct {
		CPU     string `json:"cpu" yaml:"cpu"`
		Memory  string `json:"memory" yaml:"memory"`
		Storage string `json:"storage" yaml:"storage"`
	} `json:"limits" yaml:"limits"`
}

ResourceConfig defines resource limits and requests

type ResumeCommand added in v0.2.0

type ResumeCommand struct {
	// Decisions contains one decision per interrupted action, in order
	Decisions []Decision
}

ResumeCommand represents instructions to resume from a human-in-the-loop interrupt

type RoutingCondition

type RoutingCondition struct {
	Type     string `json:"type" yaml:"type"` // "header", "query", "body", "ip"
	Key      string `json:"key" yaml:"key"`
	Value    string `json:"value" yaml:"value"`
	Operator string `json:"operator" yaml:"operator"` // "equals", "contains", "regex", "prefix", "suffix"
}

RoutingCondition defines conditions for routing

type RoutingConfig

type RoutingConfig struct {
	Type         string             `json:"type" yaml:"type"` // "path", "header", "query", "subdomain"
	DefaultAgent string             `json:"default_agent" yaml:"default_agent"`
	Rules        []RoutingRule      `json:"rules" yaml:"rules"`
	Middleware   []MiddlewareConfig `json:"middleware" yaml:"middleware"`
}

RoutingConfig defines how requests are routed to different agents

type RoutingMetrics

type RoutingMetrics struct {
	RoutingDecisions map[string]int64 `json:"routing_decisions"`
	DefaultRoutes    int64            `json:"default_routes"`
	FailedRoutes     int64            `json:"failed_routes"`
}

RoutingMetrics tracks routing statistics

type RoutingRule

type RoutingRule struct {
	ID         string                 `json:"id" yaml:"id"`
	Pattern    string                 `json:"pattern" yaml:"pattern"`
	AgentID    string                 `json:"agent_id" yaml:"agent_id"`
	Method     string                 `json:"method" yaml:"method"`
	Priority   int                    `json:"priority" yaml:"priority"`
	Conditions []RoutingCondition     `json:"conditions" yaml:"conditions"`
	Metadata   map[string]interface{} `json:"metadata" yaml:"metadata"`
}

RoutingRule defines a routing rule

type SMTPConfig

type SMTPConfig struct {
	Host     string `json:"host" yaml:"host"`
	Port     int    `json:"port" yaml:"port"`
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
	TLS      bool   `json:"tls" yaml:"tls"`
}

SMTPConfig defines SMTP configuration

type ScalingConfig

type ScalingConfig struct {
	Enabled             bool                 `json:"enabled" yaml:"enabled"`
	MinReplicas         int                  `json:"min_replicas" yaml:"min_replicas"`
	MaxReplicas         int                  `json:"max_replicas" yaml:"max_replicas"`
	TargetCPUPercent    int                  `json:"target_cpu_percent" yaml:"target_cpu_percent"`
	TargetMemoryPercent int                  `json:"target_memory_percent" yaml:"target_memory_percent"`
	ScaleUpCooldown     time.Duration        `json:"scale_up_cooldown" yaml:"scale_up_cooldown"`
	ScaleDownCooldown   time.Duration        `json:"scale_down_cooldown" yaml:"scale_down_cooldown"`
	CustomMetrics       []CustomMetricConfig `json:"custom_metrics" yaml:"custom_metrics"`
}

ScalingConfig defines scaling configuration

type SchemaConfig

type SchemaConfig struct {
	Input  *SchemaDefinition `json:"input" yaml:"input"`
	Output *SchemaDefinition `json:"output" yaml:"output"`
}

SchemaConfig defines input/output schema validation

type SchemaDefinition

type SchemaDefinition struct {
	Type       string                         `json:"type" yaml:"type"`
	Properties map[string]*PropertyDefinition `json:"properties" yaml:"properties"`
	Required   []string                       `json:"required" yaml:"required"`
	MinLength  int                            `json:"min_length" yaml:"min_length"`
	MaxLength  int                            `json:"max_length" yaml:"max_length"`
	Pattern    string                         `json:"pattern" yaml:"pattern"`
	Format     string                         `json:"format" yaml:"format"`
	Enum       []interface{}                  `json:"enum" yaml:"enum"`
	Example    interface{}                    `json:"example" yaml:"example"`
}

SchemaDefinition defines schema definition

type SecurityConfig

type SecurityConfig struct {
	Authentication *AuthConfig       `json:"authentication" yaml:"authentication"`
	Authorization  *AuthzConfig      `json:"authorization" yaml:"authorization"`
	Encryption     *EncryptionConfig `json:"encryption" yaml:"encryption"`
	RateLimit      *RateLimitConfig  `json:"rate_limit" yaml:"rate_limit"`
	CORS           *CORSConfig       `json:"cors" yaml:"cors"`
	Headers        map[string]string `json:"headers" yaml:"headers"`
}

SecurityConfig defines security configuration

type SharedConfig

type SharedConfig struct {
	Database     *DatabaseConfig               `json:"database" yaml:"database"`
	Cache        *CacheConfig                  `json:"cache" yaml:"cache"`
	Logging      *LoggingConfig                `json:"logging" yaml:"logging"`
	Monitoring   *MonitoringConfig             `json:"monitoring" yaml:"monitoring"`
	Security     *SecurityConfig               `json:"security" yaml:"security"`
	Environment  map[string]string             `json:"environment" yaml:"environment"`
	Secrets      map[string]string             `json:"secrets" yaml:"secrets"`
	LLMProviders map[string]*LLMProviderConfig `json:"llm_providers" yaml:"llm_providers"`
}

SharedConfig defines shared configuration for all agents

type SharedState added in v0.2.0

type SharedState struct {
	// contains filtered or unexported fields
}

SharedState manages state sharing across multiple subagents Provides both global state (shared across all) and local state (per-subagent)

func NewSharedState added in v0.2.0

func NewSharedState() *SharedState

NewSharedState creates a new shared state manager

func (*SharedState) Clear added in v0.2.0

func (ss *SharedState) Clear()

Clear removes all state (useful for testing)

func (*SharedState) GetAllGlobal added in v0.2.0

func (ss *SharedState) GetAllGlobal() map[string]interface{}

GetAllGlobal returns a copy of all global state (thread-safe)

func (*SharedState) GetGlobal added in v0.2.0

func (ss *SharedState) GetGlobal(key string) (interface{}, bool)

GetGlobal retrieves a value from the global shared state (thread-safe)

func (*SharedState) GetLocalState added in v0.2.0

func (ss *SharedState) GetLocalState(agentID string) *core.BaseState

GetLocalState gets or creates a local state for a specific agent

func (*SharedState) MergeFromLocal added in v0.2.0

func (ss *SharedState) MergeFromLocal(agentID string, keys []string)

MergeFromLocal merges values from a local state into global state

func (*SharedState) SetGlobal added in v0.2.0

func (ss *SharedState) SetGlobal(key string, value interface{})

SetGlobal sets a value in the global shared state (thread-safe)

func (*SharedState) SetLocalState added in v0.2.0

func (ss *SharedState) SetLocalState(agentID string, state *core.BaseState)

SetLocalState sets the local state for a specific agent

type SlackConfig

type SlackConfig struct {
	WebhookURL string `json:"webhook_url" yaml:"webhook_url"`
	Channel    string `json:"channel" yaml:"channel"`
	Username   string `json:"username" yaml:"username"`
	IconEmoji  string `json:"icon_emoji" yaml:"icon_emoji"`
}

SlackConfig defines Slack configuration

type StatusUpdate added in v0.2.0

type StatusUpdate struct {
	// Type is the type of update: "progress", "tool_call", "completion", "error"
	Type string
	// Message is a human-readable status message
	Message string
	// Metadata contains additional context
	Metadata map[string]interface{}
}

StatusUpdate represents a status notification from the agent

type SubAgentExecutor added in v0.2.0

type SubAgentExecutor struct {
	// contains filtered or unexported fields
}

SubAgentExecutor handles parallel execution of multiple subagents

func NewSubAgentExecutor added in v0.2.0

func NewSubAgentExecutor(registry *AgentRegistry) *SubAgentExecutor

NewSubAgentExecutor creates a new subagent executor

func (*SubAgentExecutor) AggregateResults added in v0.2.0

func (se *SubAgentExecutor) AggregateResults(results []SubAgentResult) (string, error)

AggregateResults combines results from multiple subagents

func (*SubAgentExecutor) ExecuteSubAgents added in v0.2.0

func (se *SubAgentExecutor) ExecuteSubAgents(
	ctx context.Context,
	requests []SubAgentRequest,
	sharedState *SharedState,
) ([]SubAgentResult, error)

ExecuteSubAgents executes multiple subagents with optional parallel execution

func (*SubAgentExecutor) SetParallel added in v0.2.0

func (se *SubAgentExecutor) SetParallel(parallel bool)

SetParallel configures whether to execute subagents in parallel

func (*SubAgentExecutor) SetTimeout added in v0.2.0

func (se *SubAgentExecutor) SetTimeout(timeout time.Duration)

SetTimeout sets the default timeout for subagent execution

type SubAgentMiddleware added in v0.2.0

type SubAgentMiddleware struct {
	BaseMiddleware
	// contains filtered or unexported fields
}

SubAgentMiddleware enables task delegation to other agents

func NewSubAgentMiddleware added in v0.2.0

func NewSubAgentMiddleware() *SubAgentMiddleware

NewSubAgentMiddleware creates a new SubAgent middleware

func (*SubAgentMiddleware) BeforeRun added in v0.2.0

func (m *SubAgentMiddleware) BeforeRun(ctx context.Context, agent *BaseAgent, input string) (string, error)

func (*SubAgentMiddleware) Name added in v0.2.0

func (m *SubAgentMiddleware) Name() string

func (*SubAgentMiddleware) RegisterSubAgent added in v0.2.0

func (m *SubAgentMiddleware) RegisterSubAgent(name string, agent Agent)

RegisterSubAgent registers a sub-agent for delegation

type SubAgentRequest added in v0.2.0

type SubAgentRequest struct {
	// AgentID is the identifier of the subagent to execute
	AgentID string
	// Input is the input to pass to the subagent
	Input string
	// Timeout is the maximum duration for subagent execution
	Timeout time.Duration
	// ShareState determines if global state should be shared
	ShareState bool
	// Messages seeds ReAct conversation history on resume (HITL mid-run).
	// When non-empty, the agent continues from this history instead of a cold start.
	Messages []llm.Message
	// Iteration restores the ReAct loop counter on resume.
	Iteration int
	// PendingToolCalls restores in-flight tool calls interrupted mid-act.
	PendingToolCalls []llm.ToolCall
	// Resume skips re-adding Input as a fresh user turn when Messages already end
	// with an equivalent user/assistant/tool exchange.
	Resume bool
	// TaskID is an optional caller tag (persisted in result metadata for checkpoints).
	TaskID string
}

SubAgentRequest represents a request to execute a subagent

type SubAgentResult added in v0.2.0

type SubAgentResult struct {
	// AgentID is the identifier of the executed subagent
	AgentID string
	// Output is the final output from the subagent
	Output interface{}
	// State is the final state after execution
	State *core.BaseState
	// Duration is how long the execution took
	Duration time.Duration
	// Error contains any error that occurred
	Error error
	// Messages is the ReAct conversation at exit (including on cancel/interrupt).
	Messages []llm.Message
	// Iteration is the ReAct loop counter at exit.
	Iteration int
	// PendingToolCalls are tool calls awaiting observation (mid-tool-call interrupt).
	PendingToolCalls []llm.ToolCall
	// Provider / Model identify the LLM backend used (for checkpoint restore).
	Provider string
	Model    string
	// TaskID echoes the request tag when set.
	TaskID string
	// Usage aggregates token counts from LLM calls (estimated when providers omit).
	Usage llm.Usage
	// UsageEstimated is true when Usage was filled by heuristics (e.g. early_exit).
	UsageEstimated bool
}

SubAgentResult contains the result of a subagent execution

type SummarizationMiddleware added in v0.2.0

type SummarizationMiddleware struct {
	BaseMiddleware
	// contains filtered or unexported fields
}

SummarizationMiddleware implements conversation summarization

func NewSummarizationMiddleware added in v0.2.0

func NewSummarizationMiddleware(maxMessages int) *SummarizationMiddleware

func (*SummarizationMiddleware) BeforeRun added in v0.2.0

func (m *SummarizationMiddleware) BeforeRun(ctx context.Context, agent *BaseAgent, input string) (string, error)

func (*SummarizationMiddleware) Name added in v0.2.0

func (m *SummarizationMiddleware) Name() string

type TLSConfig

type TLSConfig struct {
	Enabled            bool   `json:"enabled" yaml:"enabled"`
	CertFile           string `json:"cert_file" yaml:"cert_file"`
	KeyFile            string `json:"key_file" yaml:"key_file"`
	CAFile             string `json:"ca_file" yaml:"ca_file"`
	InsecureSkipVerify bool   `json:"insecure_skip_verify" yaml:"insecure_skip_verify"`
}

TLSConfig defines TLS configuration

type TodoListMiddleware added in v0.2.0

type TodoListMiddleware struct {
	BaseMiddleware
}

TodoListMiddleware implements planning capabilities

func NewTodoListMiddleware added in v0.2.0

func NewTodoListMiddleware() *TodoListMiddleware

func (*TodoListMiddleware) BeforeRun added in v0.2.0

func (m *TodoListMiddleware) BeforeRun(ctx context.Context, agent *BaseAgent, input string) (string, error)

func (*TodoListMiddleware) Name added in v0.2.0

func (m *TodoListMiddleware) Name() string

type ToolNode added in v0.2.0

type ToolNode struct {
	// contains filtered or unexported fields
}

ToolNode handles tool execution with all LangGraph features Supports parallel execution, error handling, and Command control flow

func NewToolNode added in v0.2.0

func NewToolNode(registry *tools.ToolRegistry) *ToolNode

NewToolNode creates a new tool node

func (*ToolNode) ExecuteTools added in v0.2.0

func (tn *ToolNode) ExecuteTools(
	ctx context.Context,
	toolCalls []llm.ToolCall,
	runtime *ToolRuntime,
) ([]llm.Message, *Command, error)

ExecuteTools handles tool execution with parallel support and error handling

func (*ToolNode) SetErrorHandler added in v0.2.0

func (tn *ToolNode) SetErrorHandler(handler ErrorHandlerFunc)

SetErrorHandler sets a custom error handler

func (*ToolNode) SetParallel added in v0.2.0

func (tn *ToolNode) SetParallel(parallel bool)

SetParallel sets whether tools should be executed in parallel

type ToolRuntime added in v0.2.0

type ToolRuntime struct {
	// State is the current agent state
	State *core.BaseState
	// Store provides persistent storage across sessions
	Store persistence.Store
	// ToolCallID is the unique identifier for this tool invocation
	ToolCallID string
	// ThreadID is the conversation thread identifier
	ThreadID string
}

ToolRuntime provides context and state access for tool execution This matches LangGraph's InjectedState/InjectedStore pattern

type TracingConfig

type TracingConfig struct {
	Enabled     bool    `json:"enabled" yaml:"enabled"`
	Endpoint    string  `json:"endpoint" yaml:"endpoint"`
	ServiceName string  `json:"service_name" yaml:"service_name"`
	SampleRate  float64 `json:"sample_rate" yaml:"sample_rate"`
}

TracingConfig defines tracing configuration

type VolumeConfig

type VolumeConfig struct {
	Name      string `json:"name" yaml:"name"`
	Type      string `json:"type" yaml:"type"` // "configmap", "secret", "emptydir", "persistentvolume"
	Source    string `json:"source" yaml:"source"`
	MountPath string `json:"mount_path" yaml:"mount_path"`
	ReadOnly  bool   `json:"read_only" yaml:"read_only"`
	AgentID   string `json:"agent_id" yaml:"agent_id"`
}

VolumeConfig defines volume configuration

type WebhookConfig

type WebhookConfig struct {
	URL     string            `json:"url" yaml:"url"`
	Method  string            `json:"method" yaml:"method"`
	Headers map[string]string `json:"headers" yaml:"headers"`
	Timeout time.Duration     `json:"timeout" yaml:"timeout"`
}

WebhookConfig defines webhook configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL