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
- func RegisterAgent(id string, definition AgentDefinition) error
- func RegisterAgentFactory(id string, factory AgentFactory) error
- func ValidateDecision(decision Decision, allowedActions []string) error
- func ValidateResumeCommand(resume *ResumeCommand, interrupt *InterruptData) error
- type AdvancedAgentDefinition
- func (aad *AdvancedAgentDefinition) BuildGraph() (*core.Graph, error)
- func (aad *AdvancedAgentDefinition) CreateAgent() (Agent, error)
- func (aad *AdvancedAgentDefinition) GetCustomMiddleware() ...
- func (aad *AdvancedAgentDefinition) GetCustomTools() []tools.Tool
- func (aad *AdvancedAgentDefinition) WithCustomGraph(graph *core.Graph) *AdvancedAgentDefinition
- func (aad *AdvancedAgentDefinition) WithCustomMiddleware(...) *AdvancedAgentDefinition
- func (aad *AdvancedAgentDefinition) WithCustomTools(tools ...tools.Tool) *AdvancedAgentDefinition
- func (aad *AdvancedAgentDefinition) WithGraphBuilder(builder func() (*core.Graph, error)) *AdvancedAgentDefinition
- func (aad *AdvancedAgentDefinition) WithMiddlewareProvider(provider func() ...) *AdvancedAgentDefinition
- func (aad *AdvancedAgentDefinition) WithToolsProvider(provider func() []tools.Tool) *AdvancedAgentDefinition
- type Agent
- type AgentConfig
- type AgentDefinition
- type AgentDefinitionBuilder
- func (adb *AgentDefinitionBuilder) Build() *BaseAgentDefinition
- func (adb *AgentDefinitionBuilder) WithMaxTokens(maxTokens int) *AgentDefinitionBuilder
- func (adb *AgentDefinitionBuilder) WithMetadata(key string, value interface{}) *AgentDefinitionBuilder
- func (adb *AgentDefinitionBuilder) WithModel(model string) *AgentDefinitionBuilder
- func (adb *AgentDefinitionBuilder) WithName(name string) *AgentDefinitionBuilder
- func (adb *AgentDefinitionBuilder) WithProvider(provider string) *AgentDefinitionBuilder
- func (adb *AgentDefinitionBuilder) WithSystemPrompt(prompt string) *AgentDefinitionBuilder
- func (adb *AgentDefinitionBuilder) WithTemperature(temperature float64) *AgentDefinitionBuilder
- func (adb *AgentDefinitionBuilder) WithTools(tools ...string) *AgentDefinitionBuilder
- func (adb *AgentDefinitionBuilder) WithType(agentType AgentType) *AgentDefinitionBuilder
- type AgentExecution
- type AgentFactory
- type AgentInfo
- type AgentMetrics
- type AgentRegistry
- func (ar *AgentRegistry) CreateAgentFromDefinition(id string, llmManager *llm.ProviderManager, toolRegistry *tools.ToolRegistry) (Agent, error)
- func (ar *AgentRegistry) CreateAgentFromFactory(id string, llmManager *llm.ProviderManager, toolRegistry *tools.ToolRegistry) (Agent, error)
- func (ar *AgentRegistry) GetAgentInfo() []AgentInfo
- func (ar *AgentRegistry) GetDefinition(id string) (AgentDefinition, bool)
- func (ar *AgentRegistry) GetMetadata() map[string]map[string]interface{}
- func (ar *AgentRegistry) ListDefinitions() []string
- func (ar *AgentRegistry) ListFactories() []string
- func (ar *AgentRegistry) LoadFromPlugin(pluginPath string) error
- func (ar *AgentRegistry) RegisterDefinition(id string, definition AgentDefinition) error
- func (ar *AgentRegistry) RegisterDefinitions(definitions map[string]AgentDefinition) error
- func (ar *AgentRegistry) RegisterFactory(id string, factory AgentFactory) error
- type AgentSource
- type AgentState
- type AgentStep
- type AgentType
- type AlertRule
- type AlertingConfig
- type AuthConfig
- type AuthzConfig
- type BaseAgent
- func (a *BaseAgent) ClearConversation()
- func (a *BaseAgent) ClearHistory()
- func (a *BaseAgent) DisableStreaming() error
- func (a *BaseAgent) EnableStreaming() error
- func (a *BaseAgent) Execute(ctx context.Context, input string) (*AgentExecution, error)
- func (a *BaseAgent) ExecuteThread(ctx context.Context, threadID string, input string) (*AgentExecution, error)
- func (a *BaseAgent) GetConfig() *AgentConfig
- func (a *BaseAgent) GetConversation() []llm.Message
- func (a *BaseAgent) GetExecutionHistory() []AgentExecution
- func (a *BaseAgent) GetGraph() *core.Graph
- func (a *BaseAgent) GetStreamingMode() llm.StreamMode
- func (a *BaseAgent) IsRunning() bool
- func (a *BaseAgent) IsStreamingEnabled() bool
- func (a *BaseAgent) Name() string
- func (a *BaseAgent) SeedConversation(messages []llm.Message)
- func (a *BaseAgent) SeedResumeState(messages []llm.Message, iteration int, pending []llm.ToolCall)
- func (a *BaseAgent) SetGraph(graph *core.Graph)
- func (a *BaseAgent) SetStreamingMode(mode llm.StreamMode) error
- func (a *BaseAgent) UpdateConfig(config *AgentConfig)
- type BaseAgentDefinition
- func (bad *BaseAgentDefinition) CreateAgent() (Agent, error)
- func (bad *BaseAgentDefinition) GetConfig() *AgentConfig
- func (bad *BaseAgentDefinition) GetMetadata() map[string]interface{}
- func (bad *BaseAgentDefinition) Initialize(llmManager *llm.ProviderManager, toolRegistry *tools.ToolRegistry) error
- func (bad *BaseAgentDefinition) SetMetadata(key string, value interface{})
- func (bad *BaseAgentDefinition) Validate() error
- type BaseMiddleware
- type CORSConfig
- type CacheConfig
- type Command
- type CustomAgentDefinition
- type CustomMetricConfig
- type DNSConfig
- type DatabaseConfig
- type Decision
- type DeploymentConfig
- type DeploymentState
- type EmailConfig
- type EncryptionAtRestConfig
- type EncryptionConfig
- type EncryptionInTransitConfig
- type ErrorHandlerFunc
- type ExtendedAgentConfig
- type FileBasedAgentLoader
- type FilesystemMiddleware
- type HTTPHeader
- type HealthCheckConfig
- type HealthChecker
- type HealthCheckerSnapshot
- type IngressConfig
- type IngressPath
- type IngressRule
- type IngressTLS
- type InterruptData
- type InterruptManager
- func (im *InterruptManager) Clear()
- func (im *InterruptManager) GetPending(interruptID string) (*InterruptData, error)
- func (im *InterruptManager) Interrupt(toolCalls []llm.ToolCall, allowedActions map[string][]string) (string, *InterruptData, error)
- func (im *InterruptManager) ListPending() []string
- func (im *InterruptManager) Resume(interruptID string, decisions []Decision) (*ResumeCommand, error)
- func (im *InterruptManager) SetInterruptCallback(callback func(*InterruptData))
- type LLMProviderConfig
- type LoggingConfig
- type MetricsConfig
- type Middleware
- type MiddlewareConfig
- type MiddlewareFunc
- type MonitoringConfig
- type MultiAgentConfig
- func (mac *MultiAgentConfig) GetAgentByPath(path string) (string, bool)
- func (mac *MultiAgentConfig) GetAgentPaths() map[string][]string
- func (mac *MultiAgentConfig) GetAgentPort(agentID string) int
- func (mac *MultiAgentConfig) GetEnabledAgents() map[string]*AgentConfig
- func (mac *MultiAgentConfig) IsAgentEnabled(agentID string) bool
- func (mac *MultiAgentConfig) ListAgentIDs() []string
- func (mac *MultiAgentConfig) Redacted() *MultiAgentConfig
- func (mac *MultiAgentConfig) SortedRules() []RoutingRule
- func (mac *MultiAgentConfig) Validate() error
- type MultiAgentCoordinator
- func (mac *MultiAgentCoordinator) ExecuteParallel(ctx context.Context, agentIDs []string, input string) (map[string]AgentExecution, error)
- func (mac *MultiAgentCoordinator) ExecuteSequential(ctx context.Context, agentIDs []string, initialInput string) ([]AgentExecution, error)
- func (mac *MultiAgentCoordinator) GetAgent(id string) (Agent, bool)
- func (mac *MultiAgentCoordinator) ListAgents() []string
- func (mac *MultiAgentCoordinator) RegisterAgent(id string, agent Agent)
- func (mac *MultiAgentCoordinator) RemoveAgent(id string)
- type MultiAgentManager
- func (mam *MultiAgentManager) CheckHealthNow(ctx context.Context) map[string]HealthCheckerSnapshot
- func (mam *MultiAgentManager) GetConfig() *MultiAgentConfig
- func (mam *MultiAgentManager) GetDeploymentState() *DeploymentState
- func (mam *MultiAgentManager) GetMetrics() *MultiAgentMetrics
- func (mam *MultiAgentManager) GetRouter() *mux.Router
- func (mam *MultiAgentManager) HealthCheckerStatus(agentID string) (HealthCheckerSnapshot, bool)
- func (mam *MultiAgentManager) OverallHealth() (string, map[string]string)
- func (mam *MultiAgentManager) Restart(ctx context.Context) error
- func (mam *MultiAgentManager) Start(ctx context.Context) error
- func (mam *MultiAgentManager) Stop(ctx context.Context) error
- type MultiAgentMetrics
- type NetworkingConfig
- type PortConfig
- type PropertyDefinition
- type ProxyConfig
- type RateLimit
- type RateLimitConfig
- type ResourceConfig
- type ResumeCommand
- type RoutingCondition
- type RoutingConfig
- type RoutingMetrics
- type RoutingRule
- type SMTPConfig
- type ScalingConfig
- type SchemaConfig
- type SchemaDefinition
- type SecurityConfig
- type SharedConfig
- type SharedState
- func (ss *SharedState) Clear()
- func (ss *SharedState) GetAllGlobal() map[string]interface{}
- func (ss *SharedState) GetGlobal(key string) (interface{}, bool)
- func (ss *SharedState) GetLocalState(agentID string) *core.BaseState
- func (ss *SharedState) MergeFromLocal(agentID string, keys []string)
- func (ss *SharedState) SetGlobal(key string, value interface{})
- func (ss *SharedState) SetLocalState(agentID string, state *core.BaseState)
- type SlackConfig
- type StateChange
- type StatusUpdate
- type SubAgentExecutor
- func (se *SubAgentExecutor) AggregateResults(results []SubAgentResult) (string, error)
- func (se *SubAgentExecutor) ExecuteSubAgents(ctx context.Context, requests []SubAgentRequest, sharedState *SharedState) ([]SubAgentResult, error)
- func (se *SubAgentExecutor) SetParallel(parallel bool)
- func (se *SubAgentExecutor) SetTimeout(timeout time.Duration)
- type SubAgentMiddleware
- type SubAgentRequest
- type SubAgentResult
- type SummarizationMiddleware
- type TLSConfig
- type TodoListMiddleware
- type ToolNode
- type ToolRuntime
- type TracingConfig
- type VolumeConfig
- type WebhookConfig
Constants ¶
const ( MatchExact = "exact" MatchPrefix = "prefix" MatchSuffix = "suffix" MatchContains = "contains" MatchRegex = "regex" )
Routing match modes. A rule's Match field selects how Pattern is compared against the request path.
const ( OperatorEquals = "equals" OperatorContains = "contains" OperatorPrefix = "prefix" OperatorSuffix = "suffix" OperatorRegex = "regex" )
Routing condition operators.
const ( ConditionHeader = "header" ConditionQuery = "query" ConditionIP = "ip" ConditionMethod = "method" )
Routing condition sources.
const ( DefaultHealthCheckPeriod = 10 * time.Second DefaultHealthCheckTimeout = 5 * time.Second DefaultHealthCheckFailureThreshold = 3 )
Health check defaults. A health check block that enables checking without saying how often used to reach time.NewTicker(0), which panics on a background goroutine and takes the whole process down.
const DefaultAgentExecutionTimeout = 5 * time.Minute
DefaultAgentExecutionTimeout is used when an agent config sets no timeout.
const MaxRequestBodyBytes = 1 << 20 // 1 MiB
MaxRequestBodyBytes caps how much of a request body the agent handlers will read. Without a cap a single client could stream an unbounded body into the JSON decoder and exhaust the process's memory.
const RedactedPlaceholder = "[REDACTED]"
RedactedPlaceholder replaces every secret value in a redacted config.
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 ¶
ValidateDecision validates a decision against allowed actions
func ValidateResumeCommand ¶
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 ¶
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 ¶
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 ¶
NewQuickAgent creates a QuickStart agent with default Ollama LLM
func NewSimpleAgent ¶
NewSimpleAgent creates a simple chat agent with minimal configuration
type AgentConfig ¶
type AgentConfig struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Type AgentType `json:"type" yaml:"type"`
Model string `json:"model" yaml:"model"`
Provider string `json:"provider" yaml:"provider"`
SystemPrompt string `json:"system_prompt" yaml:"system_prompt"`
Temperature float64 `json:"temperature" yaml:"temperature"`
MaxTokens int `json:"max_tokens" yaml:"max_tokens"`
MaxIterations int `json:"max_iterations" yaml:"max_iterations"`
Tools []string `json:"tools" yaml:"tools"`
EnableStreaming bool `json:"enable_streaming" yaml:"enable_streaming"`
StreamingMode llm.StreamMode `json:"streaming_mode,omitempty" yaml:"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:"-" yaml:"-"`
Timeout time.Duration `json:"timeout" yaml:"timeout"`
Metadata map[string]interface{} `json:"metadata" yaml:"metadata"`
Middleware []Middleware `json:"-" yaml:"-"`
InterruptOn []string `json:"interrupt_on" yaml:"interrupt_on"`
Checkpointer persistence.Checkpointer `json:"-" yaml:"-"`
}
AgentConfig represents agent configuration
func DefaultAgentConfig ¶
func DefaultAgentConfig() *AgentConfig
DefaultAgentConfig returns default agent configuration
func (*AgentConfig) UnmarshalYAML ¶
func (config *AgentConfig) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML accepts the documented snake_case fields while preserving the compact spellings emitted by older GoLangGraph releases. Before explicit YAML tags were added, yaml.v3 ignored the JSON tags and quietly dropped fields such as system_prompt and max_tokens from normal configuration files.
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 ¶
func (adb *AgentDefinitionBuilder) Build() *BaseAgentDefinition
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 ¶
func (adb *AgentDefinitionBuilder) WithName(name string) *AgentDefinitionBuilder
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 `json:"id"`
Input string `json:"input"`
Output interface{} `json:"output"`
// StructuredOutput carries a schema-shaped result when the agent declares
// one; Output stays a flat value for backward compatibility.
StructuredOutput interface{} `json:"structured_output,omitempty"`
Success bool `json:"success"`
StartTime time.Time `json:"timestamp"`
EndTime time.Time `json:"end_time"`
Duration time.Duration `json:"duration"`
Status string `json:"status"` // "running", "completed", "failed", "interrupted"
Steps []AgentStep `json:"steps,omitempty"`
ToolCalls []llm.ToolCall `json:"tool_calls"`
// Error holds the Go error and is not serialisable: a Go error marshals to
// an empty object, so a failed execution used to reach clients with no
// explanation at all. ErrorMessage carries the reason over the wire.
Error error `json:"-"`
ErrorMessage string `json:"error,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
// ExecutionPath lists the nodes that ran, in order, and StateChanges the
// state after each one. Studio highlights its graph view from these.
ExecutionPath []string `json:"execution_path"`
StateChanges []StateChange `json:"state_changes,omitempty"`
}
AgentExecution tracks the execution state of an agent.
Every field is tagged so the wire format is snake_case like the rest of the API; GoLangGraph Studio decodes this struct directly and Go's default PascalCase would leave every field unread.
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) RegisterDefinitions ¶
func (ar *AgentRegistry) RegisterDefinitions(definitions map[string]AgentDefinition) error
RegisterDefinitions validates and registers a group of definitions as one operation. A malformed or colliding definition leaves the registry unchanged, which is essential for a configuration reload: serving half a directory is worse than rejecting it.
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
func (*AgentState) Clone ¶
func (as *AgentState) Clone() *AgentState
Clone returns a deep copy of the agent state.
type AgentStep ¶
type AgentStep struct {
NodeID string `json:"node_id"`
Timestamp time.Time `json:"timestamp"`
Input map[string]interface{} `json:"input,omitempty"`
Output map[string]interface{} `json:"output,omitempty"`
Error error `json:"-"`
}
AgentStep represents a single step in the agent's execution
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 ¶
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 ¶
func (a *BaseAgent) ClearConversation()
ClearConversation clears the agent's conversation history
func (*BaseAgent) ClearHistory ¶
func (a *BaseAgent) ClearHistory()
ClearHistory clears the agent's execution history
func (*BaseAgent) DisableStreaming ¶
DisableStreaming disables streaming mode for the agent
func (*BaseAgent) EnableStreaming ¶
EnableStreaming enables streaming mode for the agent
func (*BaseAgent) ExecuteThread ¶
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 ¶
func (a *BaseAgent) GetConfig() *AgentConfig
GetConfig returns the agent's configuration
func (*BaseAgent) GetConversation ¶
GetConversation returns the agent's conversation history
func (*BaseAgent) GetExecutionHistory ¶
func (a *BaseAgent) GetExecutionHistory() []AgentExecution
GetExecutionHistory returns the agent's execution history
func (*BaseAgent) GetStreamingMode ¶
func (a *BaseAgent) GetStreamingMode() llm.StreamMode
GetStreamingMode returns the current streaming mode
func (*BaseAgent) IsStreamingEnabled ¶
IsStreamingEnabled returns whether streaming is enabled
func (*BaseAgent) SeedConversation ¶
SeedConversation restores prior ReAct messages for mid-run HITL resume.
func (*BaseAgent) SeedResumeState ¶
SeedResumeState restores conversation, iteration, and pending tool calls.
func (*BaseAgent) SetStreamingMode ¶
func (a *BaseAgent) SetStreamingMode(mode llm.StreamMode) error
SetStreamingMode sets the streaming mode for the agent
func (*BaseAgent) UpdateConfig ¶
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 ¶
type BaseMiddleware struct{}
BaseMiddleware provides default no-op implementations
func (*BaseMiddleware) AfterRun ¶
func (m *BaseMiddleware) AfterRun(ctx context.Context, agent *BaseAgent, result *AgentExecution) (*AgentExecution, error)
func (*BaseMiddleware) Name ¶
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 ¶
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 ¶
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
func (*DeploymentState) Clone ¶
func (ds *DeploymentState) Clone() *DeploymentState
Clone returns a deep copy of the deployment state.
GetDeploymentState and the /deployment/status handler used to dereference the struct while holding the read lock and hand the result out - but the copy shares the AgentStates map and every *AgentState in it, so callers (and the JSON encoder, after the lock was released) read fields that request handlers were concurrently writing. The race detector flags it on any concurrent load.
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 ¶
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 declarative files. The type name is retained for source compatibility with the previous API.
func NewFileBasedAgentLoader ¶
func NewFileBasedAgentLoader(registry *AgentRegistry) *FileBasedAgentLoader
NewFileBasedAgentLoader creates a declarative file-based agent loader.
func (*FileBasedAgentLoader) LoadFromDirectory ¶
func (fbal *FileBasedAgentLoader) LoadFromDirectory(directory string) error
LoadFromDirectory loads every .yaml, .yml and .json multi-agent config in a directory. Runtime compilation of arbitrary Go source was never safe or implemented; Go definitions should continue to use the explicit plugin API.
type FilesystemMiddleware ¶
type FilesystemMiddleware struct {
BaseMiddleware
// contains filtered or unexported fields
}
FilesystemMiddleware implements virtual filesystem capabilities with pluggable backends
func NewFilesystemMiddleware ¶
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) Name ¶
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
func (*HealthCheckConfig) Failures ¶
func (hc *HealthCheckConfig) Failures() int
Failures returns the consecutive-failure count that marks an agent unhealthy.
func (*HealthCheckConfig) InitialDelay ¶
func (hc *HealthCheckConfig) InitialDelay() time.Duration
InitialDelay returns how long to wait before the first check.
func (*HealthCheckConfig) Period ¶
func (hc *HealthCheckConfig) Period() time.Duration
Period returns the interval between checks, substituting a safe default for an unset value rather than handing 0 to time.NewTicker.
func (*HealthCheckConfig) Timeout ¶
func (hc *HealthCheckConfig) Timeout() time.Duration
Timeout returns the per-check timeout.
type HealthChecker ¶
type HealthChecker struct {
AgentID string
Config *HealthCheckConfig
Logger *logrus.Logger
// contains filtered or unexported fields
}
HealthChecker performs health checks for agents.
The mutable fields are guarded by mu: they are written by the checker's own goroutine and read by callers of Snapshot (and by the /health handlers), so leaving them bare was a data race waiting for the first reader.
func (*HealthChecker) Snapshot ¶
func (hc *HealthChecker) Snapshot() HealthCheckerSnapshot
Snapshot returns the checker's current state under its lock.
type HealthCheckerSnapshot ¶
type HealthCheckerSnapshot struct {
AgentID string `json:"agent_id"`
Status string `json:"status"`
LastCheck time.Time `json:"last_check"`
ConsecutiveFails int `json:"consecutive_fails"`
LastError string `json:"last_error,omitempty"`
}
HealthCheckerSnapshot is an immutable view of a checker's state.
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 ¶
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 ¶
type InterruptManager struct {
// contains filtered or unexported fields
}
InterruptManager handles interrupt lifecycle for HITL workflows
func NewInterruptManager ¶
func NewInterruptManager() *InterruptManager
NewInterruptManager creates a new interrupt manager
func (*InterruptManager) Clear ¶
func (im *InterruptManager) Clear()
Clear removes all pending interrupts
func (*InterruptManager) GetPending ¶
func (im *InterruptManager) GetPending(interruptID string) (*InterruptData, error)
GetPending retrieves a pending interrupt by ID
func (*InterruptManager) Interrupt ¶
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 ¶
func (im *InterruptManager) ListPending() []string
ListPending returns all pending interrupt IDs
func (*InterruptManager) Resume ¶
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 ¶
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 ¶
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 ¶
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"`
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)
LoadMultiAgentConfigFromFile loads multi-agent configuration from a file.
The extension chooses the decoder; the result is validated before it is returned, so a caller never receives a config the manager would reject.
func (*MultiAgentConfig) GetAgentByPath ¶
func (mac *MultiAgentConfig) GetAgentByPath(path string) (string, bool)
GetAgentByPath returns the agent ID for a given path.
Rules are consulted highest-priority-first. They used to be walked in raw declaration order, so this answered with a different agent than the HTTP router - which does sort by priority - whenever two patterns overlapped.
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) IsAgentEnabled ¶
func (mac *MultiAgentConfig) IsAgentEnabled(agentID string) bool
IsAgentEnabled reports whether an agent should be started and routed to.
An agent is disabled by setting metadata.disabled: true (or metadata.enabled: false) on its config. GetEnabledAgents previously returned every agent with a comment admitting it did no filtering at all, so a config that switched an agent off still got it created, routed to and health checked.
func (*MultiAgentConfig) ListAgentIDs ¶
func (mac *MultiAgentConfig) ListAgentIDs() []string
ListAgentIDs returns all agent IDs
func (*MultiAgentConfig) Redacted ¶
func (mac *MultiAgentConfig) Redacted() *MultiAgentConfig
Redacted returns a copy of the configuration with every credential replaced by RedactedPlaceholder.
The /config endpoint served the raw struct, so a plain unauthenticated GET returned provider API keys, database and cache passwords, SMTP credentials, Slack webhook URLs and both secret maps verbatim.
func (*MultiAgentConfig) SortedRules ¶
func (mac *MultiAgentConfig) SortedRules() []RoutingRule
SortedRules returns the routing rules ordered the way the HTTP router installs them: highest priority first, ties broken by rule ID so the order is stable across runs.
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 ¶
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) CheckHealthNow ¶
func (mam *MultiAgentManager) CheckHealthNow(ctx context.Context) map[string]HealthCheckerSnapshot
CheckHealthNow runs one health check per agent synchronously and returns the resulting snapshots. It exists so callers (and tests) can observe health without waiting a full tick.
func (*MultiAgentManager) GetConfig ¶
func (mam *MultiAgentManager) GetConfig() *MultiAgentConfig
GetConfig returns the multi-agent configuration
func (*MultiAgentManager) GetDeploymentState ¶
func (mam *MultiAgentManager) GetDeploymentState() *DeploymentState
GetDeploymentState returns a deep copy of the current deployment state.
It used to return a shallow copy sharing the live AgentStates map and every *AgentState in it, so the "snapshot" kept changing under the caller and reading it raced with request handlers.
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) HealthCheckerStatus ¶
func (mam *MultiAgentManager) HealthCheckerStatus(agentID string) (HealthCheckerSnapshot, bool)
HealthCheckerStatus returns the latest health checker state for an agent.
func (*MultiAgentManager) OverallHealth ¶
func (mam *MultiAgentManager) OverallHealth() (string, map[string]string)
OverallHealth summarizes agent health: "healthy" when every agent is, and "unhealthy" as soon as one is not.
func (*MultiAgentManager) Restart ¶
func (mam *MultiAgentManager) Restart(ctx context.Context) error
Restart rebuilds every agent from configuration and brings the manager back up. Counters and error state are reset; routing is left alone because the router is wired to agent IDs, which do not change.
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 ¶
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", "ip", "method"
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
func (RoutingCondition) Evaluate ¶
func (rc RoutingCondition) Evaluate(actual string) bool
Evaluate reports whether an actual request value satisfies the condition.
Conditions used to be pure decoration: they were parsed from config and carried around on every rule, but nothing ever compared them against a request, so a rule guarded by a condition matched every request.
func (RoutingCondition) OperatorMode ¶
func (rc RoutingCondition) OperatorMode() string
OperatorMode returns the normalized operator, defaulting to "equals".
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"`
// Match selects how Pattern is compared against the request path: one of
// exact, prefix, suffix, contains or regex. Empty means exact, which is
// what the HTTP router has always done for path routing.
//
// This field exists because matchesRule used to switch on Pattern itself
// against the literal strings "prefix"/"suffix"/"exact"/"contains", so the
// match mode could never be selected and every real pattern silently fell
// through to prefix matching - disagreeing with the HTTP router, which
// matched the same rule exactly.
Match string `json:"match,omitempty" yaml:"match,omitempty"`
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
func (RoutingRule) MatchMode ¶
func (r RoutingRule) MatchMode() string
MatchMode returns the normalized match mode for the rule.
func (RoutingRule) MatchesPath ¶
func (r RoutingRule) MatchesPath(path string) bool
MatchesPath reports whether path satisfies the rule's pattern under its match mode. An unknown mode never matches; Validate rejects those up front so a live system cannot reach this branch with a config it accepted.
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 {
}
SharedConfig defines shared configuration for all agents
type SharedState ¶
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 ¶
func NewSharedState() *SharedState
NewSharedState creates a new shared state manager
func (*SharedState) Clear ¶
func (ss *SharedState) Clear()
Clear removes all state (useful for testing)
func (*SharedState) GetAllGlobal ¶
func (ss *SharedState) GetAllGlobal() map[string]interface{}
GetAllGlobal returns a copy of all global state (thread-safe)
func (*SharedState) GetGlobal ¶
func (ss *SharedState) GetGlobal(key string) (interface{}, bool)
GetGlobal retrieves a value from the global shared state (thread-safe)
func (*SharedState) GetLocalState ¶
func (ss *SharedState) GetLocalState(agentID string) *core.BaseState
GetLocalState gets or creates a local state for a specific agent
func (*SharedState) MergeFromLocal ¶
func (ss *SharedState) MergeFromLocal(agentID string, keys []string)
MergeFromLocal merges values from a local state into global state
func (*SharedState) SetGlobal ¶
func (ss *SharedState) SetGlobal(key string, value interface{})
SetGlobal sets a value in the global shared state (thread-safe)
func (*SharedState) SetLocalState ¶
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 StateChange ¶
type StateChange struct {
NodeID string `json:"node_id"`
NodeName string `json:"node_name"`
Timestamp time.Time `json:"timestamp"`
Before map[string]interface{} `json:"before,omitempty"`
After map[string]interface{} `json:"after,omitempty"`
Duration time.Duration `json:"duration"`
}
StateChange represents a change in agent state during execution
type StatusUpdate ¶
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 ¶
type SubAgentExecutor struct {
// contains filtered or unexported fields
}
SubAgentExecutor handles parallel execution of multiple subagents
func NewSubAgentExecutor ¶
func NewSubAgentExecutor(registry *AgentRegistry) *SubAgentExecutor
NewSubAgentExecutor creates a new subagent executor
func (*SubAgentExecutor) AggregateResults ¶
func (se *SubAgentExecutor) AggregateResults(results []SubAgentResult) (string, error)
AggregateResults combines results from multiple subagents
func (*SubAgentExecutor) ExecuteSubAgents ¶
func (se *SubAgentExecutor) ExecuteSubAgents( ctx context.Context, requests []SubAgentRequest, sharedState *SharedState, ) ([]SubAgentResult, error)
ExecuteSubAgents executes multiple subagents with optional parallel execution
func (*SubAgentExecutor) SetParallel ¶
func (se *SubAgentExecutor) SetParallel(parallel bool)
SetParallel configures whether to execute subagents in parallel
func (*SubAgentExecutor) SetTimeout ¶
func (se *SubAgentExecutor) SetTimeout(timeout time.Duration)
SetTimeout sets the default timeout for subagent execution
type SubAgentMiddleware ¶
type SubAgentMiddleware struct {
BaseMiddleware
// contains filtered or unexported fields
}
SubAgentMiddleware enables task delegation to other agents
func NewSubAgentMiddleware ¶
func NewSubAgentMiddleware() *SubAgentMiddleware
NewSubAgentMiddleware creates a new SubAgent middleware
func (*SubAgentMiddleware) Name ¶
func (m *SubAgentMiddleware) Name() string
func (*SubAgentMiddleware) RegisterSubAgent ¶
func (m *SubAgentMiddleware) RegisterSubAgent(name string, agent Agent)
RegisterSubAgent registers a sub-agent for delegation
type SubAgentRequest ¶
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 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 ¶
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 ¶
type SummarizationMiddleware struct {
BaseMiddleware
// contains filtered or unexported fields
}
SummarizationMiddleware implements conversation summarization
func NewSummarizationMiddleware ¶
func NewSummarizationMiddleware(maxMessages int) *SummarizationMiddleware
func (*SummarizationMiddleware) Name ¶
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 ¶
type TodoListMiddleware struct {
BaseMiddleware
}
TodoListMiddleware implements planning capabilities
func NewTodoListMiddleware ¶
func NewTodoListMiddleware() *TodoListMiddleware
func (*TodoListMiddleware) Name ¶
func (m *TodoListMiddleware) Name() string
type ToolNode ¶
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 ¶
func NewToolNode(registry *tools.ToolRegistry) *ToolNode
NewToolNode creates a new tool node
func (*ToolNode) ExecuteTools ¶
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 ¶
func (tn *ToolNode) SetErrorHandler(handler ErrorHandlerFunc)
SetErrorHandler sets a custom error handler
func (*ToolNode) SetParallel ¶
SetParallel sets whether tools should be executed in parallel
type ToolRuntime ¶
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