agent

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertYAMLSchemaToResponseFormat

func ConvertYAMLSchemaToResponseFormat(config *ResponseFormatConfig) (*interfaces.ResponseFormat, error)

ConvertYAMLSchemaToResponseFormat converts a ResponseFormatConfig to interfaces.ResponseFormat

func CreateMemoryFromConfig

func CreateMemoryFromConfig(memoryConfig map[string]interface{}, llmClient interfaces.LLM) (interfaces.Memory, error)

CreateMemoryFromConfig creates a memory instance from YAML configuration This function is intended to be used by agent-blueprint applications that need to instantiate memory from YAML config stored in the agent

func ExpandEnv

func ExpandEnv(s string) string

ExpandEnv expands environment variables, checking both actual env vars and .env file This replaces os.ExpandEnv to support .env files

func FormatSystemPromptFromConfig

func FormatSystemPromptFromConfig(config AgentConfig, variables map[string]string) string

FormatSystemPromptFromConfig formats a system prompt based on the agent configuration

func GenerateConfigFromSystemPrompt

func GenerateConfigFromSystemPrompt(ctx context.Context, llm interfaces.LLM, systemPrompt string) (AgentConfig, []TaskConfig, error)

GenerateConfigFromSystemPrompt uses the LLM to generate agent and task configurations from a system prompt

func GetAgentForTask

func GetAgentForTask(taskConfigs TaskConfigs, taskName string) (string, error)

GetAgentForTask returns the agent name for a given task

func GetEnvValue

func GetEnvValue(key string) string

GetEnvValue gets an environment variable value from either env or .env cache

func GetInvocationID

func GetInvocationID(ctx context.Context) string

GetInvocationID retrieves the invocation ID from context

func GetParentAgent

func GetParentAgent(ctx context.Context) string

GetParentAgent retrieves the parent agent from context

func GetRecursionDepth

func GetRecursionDepth(ctx context.Context) int

GetRecursionDepth retrieves the current recursion depth from context

func GetSubAgentName

func GetSubAgentName(ctx context.Context) string

GetSubAgentName retrieves the sub-agent name from context

func IsSubAgentCall

func IsSubAgentCall(ctx context.Context) bool

IsSubAgentCall checks if the current context is a sub-agent call

func LoadEnvFile

func LoadEnvFile(path string) error

LoadEnvFile explicitly loads a .env file into the cache This can be called by applications to ensure a specific .env file is loaded

func NewAgentCreationError

func NewAgentCreationError(agentName, source string, err error) error

NewAgentCreationError creates a new agent creation error

func SaveAgentConfigsToFile

func SaveAgentConfigsToFile(configs AgentConfigs, file *os.File) error

SaveAgentConfigsToFile saves agent configurations to a YAML file

func SaveMCPConfigToJSON

func SaveMCPConfigToJSON(config *MCPConfiguration, filePath string) error

SaveMCPConfigToJSON saves MCP configuration to a JSON file

func SaveMCPConfigToYAML

func SaveMCPConfigToYAML(config *MCPConfiguration, filePath string) error

SaveMCPConfigToYAML saves MCP configuration to a YAML file

func SaveTaskConfigsToFile

func SaveTaskConfigsToFile(configs TaskConfigs, file *os.File) error

SaveTaskConfigsToFile saves task configurations to a YAML file

func ValidateConfigPath

func ValidateConfigPath(path string) error

ValidateConfigPath validates that a configuration file path is safe

func ValidateMCPConfig

func ValidateMCPConfig(config *MCPConfiguration) error

ValidateMCPConfig validates an MCP configuration

func ValidateRecursionDepth

func ValidateRecursionDepth(ctx context.Context) error

ValidateRecursionDepth checks if the recursion depth is within limits

func WithSubAgentContext

func WithSubAgentContext(ctx context.Context, parentAgent, subAgentName string) context.Context

WithSubAgentContext adds sub-agent context to the context

func WithTimeout

func WithTimeout(ctx context.Context, timeout time.Duration) (context.Context, context.CancelFunc)

WithTimeout adds a timeout to the context for sub-agent calls

Types

type Agent

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

Agent represents an AI agent

func CreateAgentForTask

func CreateAgentForTask(taskName string, agentConfigs AgentConfigs, taskConfigs TaskConfigs, variables map[string]string, options ...Option) (*Agent, error)

CreateAgentForTask creates a new agent for a specific task

func NewAgent

func NewAgent(options ...Option) (*Agent, error)

NewAgent creates a new agent with the given options

func NewAgentFromConfig

func NewAgentFromConfig(agentName string, configs AgentConfigs, variables map[string]string, options ...Option) (*Agent, error)

NewAgentFromConfig creates a new agent from a YAML configuration

func NewAgentFromConfigObject

func NewAgentFromConfigObject(ctx context.Context, config *AgentConfig, variables map[string]string, options ...Option) (*Agent, error)

NewAgentFromConfigObject creates an agent from a pre-loaded AgentConfig object This is useful when you already have a loaded configuration from any source

func NewAgentFromCreateConfig

func NewAgentFromCreateConfig(ctx context.Context, config CreateAgentConfig) (*Agent, error)

NewAgentFromCreateConfig creates an agent using a structured configuration This provides a single entry point with all options

func NewAgentFromFile

func NewAgentFromFile(ctx context.Context, configPath string, options ...Option) (*Agent, error)

NewAgentFromFile creates an agent from a specific local YAML file This is backward compatible with existing usage

func NewAgentFromFileWithName

func NewAgentFromFileWithName(ctx context.Context, configPath, agentName string, options ...Option) (*Agent, error)

NewAgentFromFileWithName creates an agent from a specific local YAML file with agent name

func NewAgentFromLocalConfig

func NewAgentFromLocalConfig(ctx context.Context, agentName, environment string, options ...Option) (*Agent, error)

NewAgentFromLocalConfig creates an agent using only local YAML files

func NewAgentFromRemoteConfig

func NewAgentFromRemoteConfig(ctx context.Context, agentName, environment string, options ...Option) (*Agent, error)

NewAgentFromRemoteConfig creates an agent using only remote configuration

func NewAgentWithAutoConfig

func NewAgentWithAutoConfig(ctx context.Context, options ...Option) (*Agent, error)

NewAgentWithAutoConfig creates a new agent with automatic configuration generation based on the system prompt if explicit configuration is not provided

func NewAgentWithDualConfig

func NewAgentWithDualConfig(ctx context.Context, agentName, environment string, options ...Option) (*Agent, error)

NewAgentWithDualConfig creates an agent with automatic configuration source detection This is the recommended entry point for new applications using centralized config management

func (*Agent) ApproveExecutionPlan

func (a *Agent) ApproveExecutionPlan(ctx context.Context, plan *executionplan.ExecutionPlan) (string, error)

ApproveExecutionPlan approves an execution plan for execution

func (*Agent) Disconnect

func (a *Agent) Disconnect() error

Disconnect closes the connection to a remote agent

func (*Agent) ExecuteTaskFromConfig

func (a *Agent) ExecuteTaskFromConfig(ctx context.Context, taskName string, taskConfigs TaskConfigs, variables map[string]string) (string, error)

ExecuteTaskFromConfig executes a task using its YAML configuration

func (*Agent) GenerateExecutionPlan

func (a *Agent) GenerateExecutionPlan(ctx context.Context, input string) (*executionplan.ExecutionPlan, error)

GenerateExecutionPlan generates an execution plan

func (*Agent) GetAllConversations

func (a *Agent) GetAllConversations(ctx context.Context) ([]string, error)

GetAllConversations returns all conversation IDs from memory

func (*Agent) GetCapabilities

func (a *Agent) GetCapabilities() string

GetCapabilities returns a description of what the agent can do

func (*Agent) GetConfig

func (a *Agent) GetConfig() *AgentConfig

GetConfig returns the agent's configuration for inspection

func (*Agent) GetConversationMessages

func (a *Agent) GetConversationMessages(ctx context.Context, conversationID string) ([]interfaces.Message, error)

GetConversationMessages gets all messages for a specific conversation

func (*Agent) GetDataStore

func (a *Agent) GetDataStore() interfaces.DataStore

GetDataStore returns the datastore instance

func (*Agent) GetDescription

func (a *Agent) GetDescription() string

GetDescription returns the description of the agent

func (*Agent) GetGeneratedAgentConfig

func (a *Agent) GetGeneratedAgentConfig() *AgentConfig

GetGeneratedAgentConfig returns the automatically generated agent configuration, if any

func (*Agent) GetGeneratedTaskConfigs

func (a *Agent) GetGeneratedTaskConfigs() TaskConfigs

GetGeneratedTaskConfigs returns the automatically generated task configurations, if any

func (*Agent) GetGraphRAGStore

func (a *Agent) GetGraphRAGStore() interfaces.GraphRAGStore

GetGraphRAGStore returns the GraphRAG store if configured. Returns nil if GraphRAG is not enabled.

func (*Agent) GetLLM

func (a *Agent) GetLLM() interfaces.LLM

GetLLM returns the LLM instance (for use in custom functions)

func (*Agent) GetLogger

func (a *Agent) GetLogger() logging.Logger

GetLogger returns the logger instance (for use in custom functions)

func (*Agent) GetMemory

func (a *Agent) GetMemory() interfaces.Memory

GetMemory returns the memory instance (for use in custom functions)

func (*Agent) GetMemoryConfig

func (a *Agent) GetMemoryConfig() map[string]interface{}

GetMemoryConfig returns the stored memory configuration from YAML This allows agent-blueprint to access the memory config for instantiation

func (*Agent) GetMemoryStatistics

func (a *Agent) GetMemoryStatistics(ctx context.Context) (totalConversations, totalMessages int, err error)

GetMemoryStatistics returns basic memory statistics

func (*Agent) GetName

func (a *Agent) GetName() string

GetName returns the agent's name

func (*Agent) GetRemoteMetadata

func (a *Agent) GetRemoteMetadata() (map[string]string, error)

GetRemoteMetadata returns metadata for remote agents, nil for local agents

func (*Agent) GetRemoteURL

func (a *Agent) GetRemoteURL() string

GetRemoteURL returns the URL of the remote agent (empty string if not remote)

func (*Agent) GetSubAgent

func (a *Agent) GetSubAgent(name string) (*Agent, bool)

GetSubAgent retrieves a sub-agent by name

func (*Agent) GetSubAgents

func (a *Agent) GetSubAgents() []*Agent

GetSubAgents returns the sub-agents slice

func (*Agent) GetSystemPrompt

func (a *Agent) GetSystemPrompt() string

GetSystemPrompt returns the system prompt (for use in custom functions)

func (*Agent) GetTaskByID

func (a *Agent) GetTaskByID(taskID string) (*executionplan.ExecutionPlan, bool)

GetTaskByID returns a task by its ID

func (*Agent) GetTools

func (a *Agent) GetTools() []interfaces.Tool

GetTools returns the tools slice (for use in custom functions)

func (*Agent) HasGraphRAG

func (a *Agent) HasGraphRAG() bool

HasGraphRAG returns true if the agent has GraphRAG capabilities enabled.

func (*Agent) HasSubAgent

func (a *Agent) HasSubAgent(name string) bool

HasSubAgent checks if a specific agent is a sub-agent

func (*Agent) IsRemote

func (a *Agent) IsRemote() bool

IsRemote returns true if this is a remote agent

func (*Agent) ListTasks

func (a *Agent) ListTasks() []*executionplan.ExecutionPlan

ListTasks returns a list of all tasks

func (*Agent) ModifyExecutionPlan

func (a *Agent) ModifyExecutionPlan(ctx context.Context, plan *executionplan.ExecutionPlan, modifications string) (*executionplan.ExecutionPlan, error)

ModifyExecutionPlan modifies an execution plan based on user input

func (*Agent) Run

func (a *Agent) Run(ctx context.Context, input string) (string, error)

Run runs the agent with the given input

func (*Agent) RunDetailed

func (a *Agent) RunDetailed(ctx context.Context, input string) (*interfaces.AgentResponse, error)

func (*Agent) RunStream

func (a *Agent) RunStream(ctx context.Context, input string) (<-chan interfaces.AgentStreamEvent, error)

RunStream executes the agent with streaming response

func (*Agent) RunStreamWithAuth

func (a *Agent) RunStreamWithAuth(ctx context.Context, input string, authToken string) (<-chan interfaces.AgentStreamEvent, error)

RunStreamWithAuth executes the agent with streaming response and explicit auth token

func (*Agent) RunWithAuth

func (a *Agent) RunWithAuth(ctx context.Context, input string, authToken string) (string, error)

func (*Agent) RunWithAuthDetailed

func (a *Agent) RunWithAuthDetailed(ctx context.Context, input string, authToken string) (*interfaces.AgentResponse, error)

func (*Agent) SetDataStore

func (a *Agent) SetDataStore(datastore interfaces.DataStore)

SetDataStore sets the datastore for the agent

type AgentConfig

type AgentConfig struct {
	Role           string                `yaml:"role"`
	Goal           string                `yaml:"goal"`
	Backstory      string                `yaml:"backstory"`
	ResponseFormat *ResponseFormatConfig `yaml:"response_format,omitempty"`
	MCP            *MCPConfiguration     `yaml:"mcp,omitempty"`

	// NEW: Behavioral settings
	MaxIterations       *int  `yaml:"max_iterations,omitempty"`
	RequirePlanApproval *bool `yaml:"require_plan_approval,omitempty"`

	// NEW: Complex configuration objects
	StreamConfig *StreamConfigYAML `yaml:"stream_config,omitempty"`
	LLMConfig    *LLMConfigYAML    `yaml:"llm_config,omitempty"`

	// NEW: LLM Provider configuration
	LLMProvider *LLMProviderYAML `yaml:"llm_provider,omitempty"`

	// NEW: Tool configurations
	Tools []ToolConfigYAML `yaml:"tools,omitempty"`

	// NEW: Memory configuration (config only)
	Memory *MemoryConfigYAML `yaml:"memory,omitempty"`

	// NEW: Runtime settings
	Runtime *RuntimeConfigYAML `yaml:"runtime,omitempty"`

	// NEW: Sub-agents configuration (recursive)
	SubAgents map[string]AgentConfig `yaml:"sub_agents,omitempty"`

	// NEW: Configuration source metadata
	ConfigSource *ConfigSourceMetadata `yaml:"config_source,omitempty" json:"config_source,omitempty"`
}

AgentConfig represents the configuration for an agent loaded from YAML

func ExpandAgentConfig

func ExpandAgentConfig(config AgentConfig) AgentConfig

ExpandAgentConfig expands environment variables in agent configuration. Environment variables in the config are expanded with the following priority:

  1. ConfigSource.Variables (from config service - highest priority)
  2. OS environment variables
  3. .env file cache (lowest priority)

type AgentConfigs

type AgentConfigs map[string]AgentConfig

AgentConfigs represents a map of agent configurations

func LoadAgentConfigsFromDir

func LoadAgentConfigsFromDir(dirPath string) (AgentConfigs, error)

LoadAgentConfigsFromDir loads all agent configurations from YAML files in a directory

func LoadAgentConfigsFromFile

func LoadAgentConfigsFromFile(filePath string) (AgentConfigs, error)

LoadAgentConfigsFromFile loads agent configurations from a YAML file

type AgentCreationError

type AgentCreationError struct {
	AgentName string
	Source    string
	Err       error
}

AgentCreationError represents errors that occur during agent creation

func (*AgentCreationError) Error

func (e *AgentCreationError) Error() string

func (*AgentCreationError) Unwrap

func (e *AgentCreationError) Unwrap() error

type AgentToolWrapper

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

AgentToolWrapper is a simple wrapper for agent tools (placeholder implementation) This would normally use the actual tools.AgentTool implementation

func (*AgentToolWrapper) Description

func (atw *AgentToolWrapper) Description() string

Description implements interfaces.Tool.Description

func (*AgentToolWrapper) Execute

func (atw *AgentToolWrapper) Execute(ctx context.Context, args string) (string, error)

Execute implements interfaces.Tool.Execute

func (*AgentToolWrapper) Name

func (atw *AgentToolWrapper) Name() string

Name implements interfaces.Tool.Name

func (*AgentToolWrapper) Parameters

func (atw *AgentToolWrapper) Parameters() map[string]interfaces.ParameterSpec

Parameters implements interfaces.Tool.Parameters

func (*AgentToolWrapper) Run

func (atw *AgentToolWrapper) Run(ctx context.Context, input string) (string, error)

Run implements interfaces.Tool.Run

type ConfigSourceMetadata

type ConfigSourceMetadata struct {
	Type        string            `yaml:"type" json:"type"`     // "local", "remote"
	Source      string            `yaml:"source" json:"source"` // file path or service URL
	AgentID     string            `yaml:"agent_id,omitempty" json:"agent_id,omitempty"`
	AgentName   string            `yaml:"agent_name,omitempty" json:"agent_name,omitempty"`
	Environment string            `yaml:"environment,omitempty" json:"environment,omitempty"`
	Variables   map[string]string `yaml:"variables,omitempty" json:"variables,omitempty"`
	LoadedAt    time.Time         `yaml:"loaded_at" json:"loaded_at"`
}

ConfigSourceMetadata tracks where a configuration was loaded from

type ContextKey

type ContextKey string

ContextKey is a type for context keys to avoid collisions

const (
	// SubAgentNameKey is the context key for sub-agent name
	SubAgentNameKey ContextKey = "sub_agent_name"

	// ParentAgentKey is the context key for parent agent
	ParentAgentKey ContextKey = "parent_agent"

	// RecursionDepthKey is the context key for recursion depth
	RecursionDepthKey ContextKey = "recursion_depth"

	// InvocationIDKey is the context key for invocation ID
	InvocationIDKey ContextKey = "invocation_id"

	// MaxRecursionDepth is the maximum allowed recursion depth
	MaxRecursionDepth = 5

	// DefaultSubAgentTimeout is the default timeout for sub-agent calls
	DefaultSubAgentTimeout = 30 * time.Second
)

type CreateAgentConfig

type CreateAgentConfig struct {
	// Source configuration
	AgentName   string
	Environment string
	ConfigPath  string // For local file loading

	// Loading options
	PreferRemote       bool
	AllowFallback      bool
	CacheTimeout       time.Duration
	EnableEnvOverrides bool
	Verbose            bool

	// Agent options
	MaxIterations       *int
	RequirePlanApproval *bool
	CustomOptions       []Option
}

CreateAgentConfig represents options for creating agents from configuration

type CreateOption

type CreateOption func(*Agent) error

CreateOption represents functional options for agent creation

type CustomRunFunction

type CustomRunFunction func(ctx context.Context, input string, agent *Agent) (string, error)

CustomRunFunction represents a custom function that can replace the default Run behavior

type CustomRunStreamFunction

type CustomRunStreamFunction func(ctx context.Context, input string, agent *Agent) (<-chan interfaces.AgentStreamEvent, error)

CustomRunStreamFunction represents a custom function that can replace the default RunStream behavior

type LLMConfigYAML

type LLMConfigYAML struct {
	Temperature      *float64 `yaml:"temperature,omitempty"`
	TopP             *float64 `yaml:"top_p,omitempty"`
	FrequencyPenalty *float64 `yaml:"frequency_penalty,omitempty"`
	PresencePenalty  *float64 `yaml:"presence_penalty,omitempty"`
	StopSequences    []string `yaml:"stop_sequences,omitempty"`
	EnableReasoning  *bool    `yaml:"enable_reasoning,omitempty"`
	ReasoningBudget  *int     `yaml:"reasoning_budget,omitempty"`
	Reasoning        *string  `yaml:"reasoning,omitempty"`
}

LLMConfigYAML represents LLM configuration in YAML

type LLMProviderYAML

type LLMProviderYAML struct {
	Provider string                 `yaml:"provider"`
	Model    string                 `yaml:"model,omitempty"`
	Config   map[string]interface{} `yaml:"config,omitempty"`
}

LLMProviderYAML represents LLM provider configuration in YAML

type LazyMCPConfig

type LazyMCPConfig struct {
	Name              string
	Type              string // "stdio" or "http"
	Command           string
	Args              []string
	Env               []string
	URL               string
	Token             string // Bearer token for HTTP authentication
	Tools             []LazyMCPToolConfig
	HttpTransportMode string // "sse" or "streamable"
}

LazyMCPConfig holds configuration for lazy MCP server initialization

type LazyMCPToolConfig

type LazyMCPToolConfig struct {
	Name        string
	Description string
	Schema      interface{}
}

LazyMCPToolConfig holds configuration for a lazy MCP tool

type MCPConfiguration

type MCPConfiguration struct {
	MCPServers map[string]MCPServerConfig `json:"mcpServers" yaml:"mcpServers"`
	Global     *MCPGlobalConfig           `json:"global,omitempty" yaml:"global,omitempty"`
}

MCPConfiguration represents the complete MCP configuration

func GetMCPConfigFromAgent

func GetMCPConfigFromAgent(a *Agent) *MCPConfiguration

GetMCPConfigFromAgent extracts MCP configuration from an agent

func LoadMCPConfigFromJSON

func LoadMCPConfigFromJSON(filePath string) (*MCPConfiguration, error)

LoadMCPConfigFromJSON loads MCP configuration from a JSON file

func LoadMCPConfigFromYAML

func LoadMCPConfigFromYAML(filePath string) (*MCPConfiguration, error)

LoadMCPConfigFromYAML loads MCP configuration from a YAML file

type MCPDiscoveredCapabilities

type MCPDiscoveredCapabilities struct {
	SupportsTools     bool `json:"supportsTools,omitempty"`
	SupportsResources bool `json:"supportsResources,omitempty"`
	SupportsPrompts   bool `json:"supportsPrompts,omitempty"`
}

MCPDiscoveredCapabilities represents capabilities discovered from the server

type MCPDiscoveredServerInfo

type MCPDiscoveredServerInfo struct {
	Name         string                     `json:"name,omitempty"`
	Title        string                     `json:"title,omitempty"`
	Version      string                     `json:"version,omitempty"`
	Capabilities *MCPDiscoveredCapabilities `json:"capabilities,omitempty"`
}

MCPDiscoveredServerInfo represents metadata discovered from the server at runtime

type MCPGlobalConfig

type MCPGlobalConfig struct {
	Timeout         string `json:"timeout,omitempty" yaml:"timeout,omitempty"` // e.g., "30s"
	RetryAttempts   int    `json:"retry_attempts,omitempty" yaml:"retry_attempts,omitempty"`
	HealthCheck     *bool  `json:"health_check,omitempty" yaml:"health_check,omitempty"`
	EnableResources *bool  `json:"enable_resources,omitempty" yaml:"enable_resources,omitempty"`
	EnablePrompts   *bool  `json:"enable_prompts,omitempty" yaml:"enable_prompts,omitempty"`
	EnableSampling  *bool  `json:"enable_sampling,omitempty" yaml:"enable_sampling,omitempty"`
	EnableSchemas   *bool  `json:"enable_schemas,omitempty" yaml:"enable_schemas,omitempty"`
	LogLevel        string `json:"log_level,omitempty" yaml:"log_level,omitempty"`
}

MCPGlobalConfig represents global MCP settings

type MCPServerConfig

type MCPServerConfig struct {
	Command           string            `json:"command,omitempty" yaml:"command,omitempty"`
	Args              []string          `json:"args,omitempty" yaml:"args,omitempty"`
	Env               map[string]string `json:"env,omitempty" yaml:"env,omitempty"`
	URL               string            `json:"url,omitempty" yaml:"url,omitempty"`
	Token             string            `json:"token,omitempty" yaml:"token,omitempty"`
	HttpTransportMode string            `json:"httpTransportMode,omitempty" yaml:"httpTransportMode,omitempty"` // "sse" or "streamable"
}

MCPServerConfig represents a single MCP server configuration

func (*MCPServerConfig) GetServerType

func (c *MCPServerConfig) GetServerType() string

GetServerType returns the server type based on configuration

type MemoryConfigYAML

type MemoryConfigYAML struct {
	Type   string                 `yaml:"type"` // "buffer", "redis", "vector"
	Config map[string]interface{} `yaml:"config,omitempty"`
}

MemoryConfigYAML represents memory configuration in YAML

type Option

type Option func(*Agent)

Option represents an option for configuring an agent

func WithAgentConfig

func WithAgentConfig(config AgentConfig, variables map[string]string) Option

WithAgentConfig sets the agent configuration from a YAML config

func WithAgents

func WithAgents(subAgents ...*Agent) Option

WithAgents sets the sub-agents that can be called as tools

func WithConfigFile

func WithConfigFile(filePath, agentName string) Option

WithConfigFile loads configuration from a file and creates the agent This is a convenience option that combines file loading with agent creation

func WithCustomRunFunction

func WithCustomRunFunction(fn CustomRunFunction) Option

WithCustomRunFunction sets a custom run function that replaces the default Run behavior

func WithCustomRunStreamFunction

func WithCustomRunStreamFunction(fn CustomRunStreamFunction) Option

WithCustomRunStreamFunction sets a custom streaming run function that replaces the default RunStream behavior

func WithDataStore

func WithDataStore(datastore interfaces.DataStore) Option

WithDataStore sets the datastore for the agent

func WithDescription

func WithDescription(description string) Option

WithDescription sets the description for the agent

func WithGraphRAG

func WithGraphRAG(store interfaces.GraphRAGStore) Option

WithGraphRAG adds GraphRAG capabilities to the agent. When a GraphRAGStore is provided, the agent automatically registers GraphRAG tools (search, add_entity, add_relationship, get_context, extract).

func WithGuardrails

func WithGuardrails(guardrails interfaces.Guardrails) Option

WithGuardrails sets the guardrails for the agent

func WithLLM

func WithLLM(llm interfaces.LLM) Option

WithLLM sets the LLM for the agent

func WithLLMConfig

func WithLLMConfig(config interfaces.LLMConfig) Option

func WithLazyMCPConfigs

func WithLazyMCPConfigs(configs []LazyMCPConfig) Option

WithLazyMCPConfigs sets the lazy MCP server configurations for the agent

func WithLogger

func WithLogger(logger logging.Logger) Option

WithLogger sets the logger for the agent

func WithMCPConfig

func WithMCPConfig(config *MCPConfiguration) Option

WithMCPConfig adds MCP servers from configuration object

func WithMCPConfigFromJSON

func WithMCPConfigFromJSON(filePath string) Option

WithMCPConfigFromJSON adds MCP servers from a JSON configuration file

func WithMCPConfigFromYAML

func WithMCPConfigFromYAML(filePath string) Option

WithMCPConfigFromYAML adds MCP servers from a YAML configuration file

func WithMCPPresets

func WithMCPPresets(presetNames ...string) Option

WithMCPPresets adds predefined MCP server configurations

func WithMCPServers

func WithMCPServers(mcpServers []interfaces.MCPServer) Option

WithMCPServers sets the MCP servers for the agent

func WithMCPURLs

func WithMCPURLs(urls ...string) Option

WithMCPURLs adds MCP servers from URL strings Supports formats: - stdio://command/path/to/executable - http://localhost:8080/mcp - https://api.example.com/mcp?token=xxx - mcp://preset-name (for presets)

func WithMaxIterations

func WithMaxIterations(maxIterations int) Option

WithMaxIterations sets the maximum number of tool-calling iterations for the agent

func WithMemory

func WithMemory(memory interfaces.Memory) Option

WithMemory sets the memory for the agent

func WithName

func WithName(name string) Option

WithName sets the name for the agent

func WithOrgID

func WithOrgID(orgID string) Option

WithOrgID sets the organization ID for multi-tenancy

func WithRemoteTimeout

func WithRemoteTimeout(timeout time.Duration) Option

WithRemoteTimeout sets the timeout for remote agent operations

func WithRequirePlanApproval

func WithRequirePlanApproval(require bool) Option

WithRequirePlanApproval sets whether execution plans require user approval

func WithResponseFormat

func WithResponseFormat(formatType interfaces.ResponseFormat) Option

WithResponseFormat sets the response format for the agent

func WithStreamConfig

func WithStreamConfig(config *interfaces.StreamConfig) Option

WithStreamConfig sets the streaming configuration for the agent

func WithSystemPrompt

func WithSystemPrompt(prompt string) Option

WithSystemPrompt sets the system prompt for the agent

func WithTools

func WithTools(tools ...interfaces.Tool) Option

WithTools appends tools to the agent's tool list, deduplicating by name

func WithURL

func WithURL(url string) Option

WithURL creates a remote agent that communicates via gRPC

type ResponseFormatConfig

type ResponseFormatConfig struct {
	Type             string                 `yaml:"type"`
	SchemaName       string                 `yaml:"schema_name"`
	SchemaDefinition map[string]interface{} `yaml:"schema_definition"`
}

ResponseFormatConfig represents the configuration for the response format of an agent or task

type RuntimeConfigYAML

type RuntimeConfigYAML struct {
	LogLevel        string `yaml:"log_level,omitempty"` // "debug", "info", "warn", "error"
	EnableTracing   *bool  `yaml:"enable_tracing,omitempty"`
	EnableMetrics   *bool  `yaml:"enable_metrics,omitempty"`
	TimeoutDuration string `yaml:"timeout_duration,omitempty"` // "30s", "5m"
}

RuntimeConfigYAML represents runtime behavior settings in YAML

type StreamConfigYAML

type StreamConfigYAML struct {
	BufferSize                  *int  `yaml:"buffer_size,omitempty"`
	IncludeToolProgress         *bool `yaml:"include_tool_progress,omitempty"`
	IncludeIntermediateMessages *bool `yaml:"include_intermediate_messages,omitempty"`
}

StreamConfigYAML represents streaming configuration in YAML

type SubAgentContext

type SubAgentContext struct {
	ParentAgent    string
	SubAgentName   string
	RecursionDepth int
	InvocationID   string
	StartTime      time.Time
}

SubAgentContext contains context information for sub-agent invocations

type TaskConfig

type TaskConfig struct {
	Description    string                `yaml:"description"`
	ExpectedOutput string                `yaml:"expected_output"`
	Agent          string                `yaml:"agent"`
	OutputFile     string                `yaml:"output_file,omitempty"`
	ResponseFormat *ResponseFormatConfig `yaml:"response_format,omitempty"`
}

TaskConfig represents a task definition loaded from YAML

type TaskConfigs

type TaskConfigs map[string]TaskConfig

TaskConfigs represents a map of task configurations

func LoadTaskConfigsFromDir

func LoadTaskConfigsFromDir(dirPath string) (TaskConfigs, error)

LoadTaskConfigsFromDir loads all task configurations from YAML files in a directory

func LoadTaskConfigsFromFile

func LoadTaskConfigsFromFile(filePath string) (TaskConfigs, error)

LoadTaskConfigsFromFile loads task configurations from a YAML file

type ToolConfigYAML

type ToolConfigYAML struct {
	Type        string                 `yaml:"type"` // "builtin", "custom", "mcp", "agent"
	Name        string                 `yaml:"name"`
	Description string                 `yaml:"description,omitempty"`
	Config      map[string]interface{} `yaml:"config,omitempty"`
	Enabled     *bool                  `yaml:"enabled,omitempty"`

	// For agent tools
	URL     string `yaml:"url,omitempty"`     // Remote agent URL
	Timeout string `yaml:"timeout,omitempty"` // Timeout duration
}

ToolConfigYAML represents tool configuration in YAML

type ToolFactory

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

ToolFactory creates tools from YAML configuration

func NewToolFactory

func NewToolFactory() *ToolFactory

NewToolFactory creates a new tool factory with builtin tools registered

func (*ToolFactory) CreateTool

func (tf *ToolFactory) CreateTool(config ToolConfigYAML) (interfaces.Tool, error)

CreateTool creates a tool from YAML configuration

func (*ToolFactory) CreateToolWithParentConfig

func (tf *ToolFactory) CreateToolWithParentConfig(config ToolConfigYAML, parentConfig *AgentConfig) (interfaces.Tool, error)

CreateToolWithParentConfig creates a tool from YAML configuration with access to parent agent config

func (*ToolFactory) RegisterCustomTool

func (tf *ToolFactory) RegisterCustomTool(name string, factory func(map[string]interface{}) (interfaces.Tool, error))

RegisterCustomTool allows external registration of custom tools

Jump to

Keyboard shortcuts

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