Documentation
¶
Index ¶
- Variables
- func Run(configPath string) error
- func RunWithConfig(config *Config) error
- func RunWithConfigAndRuntime(config *Config, rt agent.Runtime) error
- func RunWithMCP(configPath string, servers ...*mcp.Server) error
- func StartAgents(agents map[string]agent.Agent, agentDefs []agent.AgentDef, rt agent.Runtime) error
- type CheckpointConfig
- type Config
- type ConfigLoader
- type FileReader
- type MCPAuthDef
- type MCPServerDef
- type MockFileReader
- type ModelServiceDef
- type OSFileReader
- type PhasedStarter
- type Runtime
- func (r *Runtime) Broadcast(msg *agent.Message) error
- func (r *Runtime) Call(ctx context.Context, target string, input *agent.Message) (*agent.Message, error)
- func (r *Runtime) CallParallel(ctx context.Context, targets []string, input *agent.Message) (map[string]*agent.Message, map[string]error)
- func (r *Runtime) CallWithSession(ctx context.Context, target string, input *pubagent.Message, sessionID string) (*pubagent.Message, error)
- func (r *Runtime) Config() RuntimeConfig
- func (r *Runtime) Get(name string) (agent.Agent, error)
- func (r *Runtime) GetChannelStats(name string) (capacity, length int, err error)
- func (r *Runtime) List() []string
- func (r *Runtime) MessagesSent() uint64
- func (r *Runtime) Recv(source string) (<-chan *agent.Message, error)
- func (r *Runtime) Register(a agent.Agent) error
- func (r *Runtime) Send(target string, msg *agent.Message) error
- func (r *Runtime) SessionManager() session.Manager
- func (r *Runtime) SetSessionManager(sm session.Manager)
- func (r *Runtime) Start(ctx context.Context) error
- func (r *Runtime) StartAgentsPhased(ctx context.Context, agentDefs map[string]agent.AgentDef) error
- func (r *Runtime) Stop(ctx context.Context) error
- func (r *Runtime) Unregister(name string) error
- type RuntimeConfig
- type RuntimeOption
- func WithAgentStartTimeout(timeout time.Duration) RuntimeOption
- func WithChannelBufferSize(size int) RuntimeOption
- func WithMaxConcurrentCalls(max int) RuntimeOption
- func WithMetrics(enabled bool) RuntimeOption
- func WithSendTimeout(timeout time.Duration) RuntimeOption
- func WithTracing(enabled bool) RuntimeOption
- type SessionConfig
- type SupervisorDef
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAgentNotFound is returned when an agent is not registered ErrAgentNotFound = errors.New("agent not found") // ErrAgentAlreadyRegistered is returned when trying to register an agent with a duplicate name ErrAgentAlreadyRegistered = errors.New("agent already registered") // ErrAgentNotReady is returned when trying to execute an agent that is not ready ErrAgentNotReady = errors.New("agent not ready") // ErrRuntimeNotStarted is returned when trying to use a runtime that hasn't been started ErrRuntimeNotStarted = errors.New("runtime not started") // ErrRuntimeAlreadyStarted is returned when trying to start an already running runtime ErrRuntimeAlreadyStarted = errors.New("runtime already started") // ErrSessionManagerNotConfigured is returned when calling session methods without a session manager ErrSessionManagerNotConfigured = errors.New("session manager not configured") )
Runtime errors
Functions ¶
func RunWithConfig ¶
RunWithConfig starts the aixgo agent system with the provided config
func RunWithConfigAndRuntime ¶
RunWithConfigAndRuntime starts the system with a custom runtime (useful for testing)
func RunWithMCP ¶
RunWithMCP starts the aixgo agent system with optional MCP servers
func StartAgents ¶
StartAgents starts all agents with the given runtime using dependency-aware phased startup. If the runtime supports PhasedStarter interface, agents are started in topological order based on their depends_on declarations. Otherwise, agents are started concurrently.
Types ¶
type CheckpointConfig ¶ added in v0.3.0
type CheckpointConfig struct {
// AutoSave enables automatic checkpoint creation.
AutoSave bool `yaml:"auto_save"`
// Interval is the auto-save interval (e.g., "5m").
Interval string `yaml:"interval"`
}
CheckpointConfig holds checkpoint-specific settings.
type Config ¶
type Config struct {
Supervisor SupervisorDef `yaml:"supervisor,omitempty"`
MCPServers []MCPServerDef `yaml:"mcp_servers,omitempty"`
ModelServices []ModelServiceDef `yaml:"model_services,omitempty"`
Agents []agent.AgentDef `yaml:"agents"`
Session SessionConfig `yaml:"session,omitempty"`
}
Config represents the top-level configuration
type ConfigLoader ¶
type ConfigLoader struct {
// contains filtered or unexported fields
}
ConfigLoader loads configuration from a file
func NewConfigLoader ¶
func NewConfigLoader(fr FileReader) *ConfigLoader
NewConfigLoader creates a new config loader with default security limits
func NewConfigLoaderWithLimits ¶
func NewConfigLoaderWithLimits(fr FileReader, limits security.YAMLLimits) *ConfigLoader
NewConfigLoaderWithLimits creates a new config loader with custom YAML security limits
func (*ConfigLoader) LoadConfig ¶
func (cl *ConfigLoader) LoadConfig(configPath string) (*Config, error)
LoadConfig loads and parses a config file with security limits
type FileReader ¶
FileReader interface for reading files (testable)
type MCPAuthDef ¶
type MCPAuthDef struct {
Type string `yaml:"type"` // "bearer", "oauth"
Token string `yaml:"token,omitempty"`
TokenEnv string `yaml:"token_env,omitempty"`
}
MCPAuthDef represents MCP authentication configuration
type MCPServerDef ¶
type MCPServerDef struct {
Name string `yaml:"name"`
Transport string `yaml:"transport"` // "local" or "grpc"
Address string `yaml:"address,omitempty"`
TLS bool `yaml:"tls,omitempty"`
Auth *MCPAuthDef `yaml:"auth,omitempty"`
}
MCPServerDef represents an MCP server configuration
type MockFileReader ¶
type MockFileReader struct {
// contains filtered or unexported fields
}
MockFileReader is a mock implementation of FileReader for testing
func NewMockFileReader ¶
func NewMockFileReader() *MockFileReader
NewMockFileReader creates a new mock file reader
func (*MockFileReader) AddFile ¶
func (m *MockFileReader) AddFile(path string, content []byte)
AddFile adds a file to the mock file system
func (*MockFileReader) ReadFile ¶
func (m *MockFileReader) ReadFile(path string) ([]byte, error)
ReadFile implements FileReader.ReadFile
func (*MockFileReader) SetError ¶
func (m *MockFileReader) SetError(err error)
SetError sets an error to return from ReadFile
type ModelServiceDef ¶
type ModelServiceDef struct {
Name string `yaml:"name"`
Provider string `yaml:"provider"` // "huggingface", "openai", etc.
Model string `yaml:"model"` // Model ID
Runtime string `yaml:"runtime"` // "ollama", "vllm", "cloud"
Transport string `yaml:"transport"` // "local", "grpc"
Address string `yaml:"address,omitempty"`
Config map[string]any `yaml:"config,omitempty"`
}
ModelServiceDef represents a model service configuration
type PhasedStarter ¶ added in v0.2.3
type PhasedStarter interface {
StartAgentsPhased(ctx context.Context, agentDefs map[string]agent.AgentDef) error
}
PhasedStarter is implemented by runtimes that support phased agent startup. This enables dependency-aware startup ordering.
type Runtime ¶ added in v0.3.0
type Runtime struct {
// contains filtered or unexported fields
}
Runtime is the unified in-memory runtime for agent orchestration. It provides:
- Agent registration and lifecycle management
- Synchronous (Call) and asynchronous (Send/Recv) messaging
- Session persistence and session-aware execution
- Optional observability (metrics and tracing)
- Configurable concurrency limits
This is the recommended runtime for single-process deployments. For multi-node deployments, use DistributedRuntime.
func NewRuntime ¶ added in v0.3.0
func NewRuntime(opts ...RuntimeOption) *Runtime
NewRuntime creates a new Runtime with the given options.
Example:
// Basic runtime (zero-config)
rt := aixgo.NewRuntime()
// With observability
rt := aixgo.NewRuntime(
aixgo.WithMetrics(true),
aixgo.WithTracing(true),
)
// With concurrency limits
rt := aixgo.NewRuntime(
aixgo.WithMaxConcurrentCalls(10),
)
func (*Runtime) Broadcast ¶ added in v0.3.0
Broadcast sends a message to all registered agents asynchronously. Returns the first error encountered, if any.
func (*Runtime) Call ¶ added in v0.3.0
func (r *Runtime) Call(ctx context.Context, target string, input *agent.Message) (*agent.Message, error)
Call invokes an agent synchronously and waits for response. If tracing is enabled, this creates an OpenTelemetry span.
func (*Runtime) CallParallel ¶ added in v0.3.0
func (r *Runtime) CallParallel(ctx context.Context, targets []string, input *agent.Message) (map[string]*agent.Message, map[string]error)
CallParallel invokes multiple agents concurrently and returns all results. The number of concurrent calls is limited by MaxConcurrentCalls if configured.
func (*Runtime) CallWithSession ¶ added in v0.3.0
func (r *Runtime) CallWithSession( ctx context.Context, target string, input *pubagent.Message, sessionID string, ) (*pubagent.Message, error)
CallWithSession invokes an agent with session context. The input message is appended to the session before execution, and the result is appended after execution.
If the agent implements session.SessionAwareAgent, it will receive the full conversation history during execution. Otherwise, the session is still used for persistence but the agent won't have direct access to history.
func (*Runtime) Config ¶ added in v0.3.0
func (r *Runtime) Config() RuntimeConfig
Config returns a copy of the runtime configuration.
func (*Runtime) GetChannelStats ¶ added in v0.3.0
GetChannelStats returns statistics for a channel. Returns capacity, current length, and an error if the channel doesn't exist.
func (*Runtime) MessagesSent ¶ added in v0.3.0
MessagesSent returns the total number of messages sent via Send().
func (*Runtime) Recv ¶ added in v0.3.0
Recv returns a channel to receive messages from a source agent. If the source channel doesn't exist, it will be created.
func (*Runtime) Send ¶ added in v0.3.0
Send sends a message to a target agent asynchronously. If the target channel doesn't exist, it will be created. Returns an error if the channel is full after the send timeout.
func (*Runtime) SessionManager ¶ added in v0.3.0
SessionManager returns the session manager, if configured.
func (*Runtime) SetSessionManager ¶ added in v0.3.0
SetSessionManager sets the session manager for the runtime. This enables session-aware agent calls via CallWithSession.
func (*Runtime) Start ¶ added in v0.3.0
Start starts the runtime. Must be called before Call, CallParallel, or StartAgentsPhased.
func (*Runtime) StartAgentsPhased ¶ added in v0.3.0
StartAgentsPhased starts all registered agents in dependency order. Agents are started in phases based on their dependencies:
- Phase 0: Agents with no dependencies
- Phase N: Agents whose dependencies are all in phases < N
Within each phase, agents are started concurrently and the method waits for all of them to report Ready() before proceeding to the next phase.
func (*Runtime) Stop ¶ added in v0.3.0
Stop gracefully shuts down the runtime. All agents are stopped and all channels are closed.
func (*Runtime) Unregister ¶ added in v0.3.0
Unregister removes an agent from the runtime
type RuntimeConfig ¶ added in v0.3.0
type RuntimeConfig struct {
// ChannelBufferSize sets the buffer size for message channels
// Default: 100
ChannelBufferSize int
// MaxConcurrentCalls limits parallel agent executions (0 = unlimited)
// Default: 0 (unlimited)
MaxConcurrentCalls int
// EnableMetrics enables runtime performance metrics collection
// Default: false (for backwards compatibility)
EnableMetrics bool
// EnableTracing enables OpenTelemetry tracing
// Default: false (for backwards compatibility)
EnableTracing bool
// AgentStartTimeout is the maximum time to wait for an agent to become ready
// Default: 30 seconds
AgentStartTimeout time.Duration
// SendTimeout is the timeout for Send operations
// Default: 5 seconds
SendTimeout time.Duration
// ChannelFullWarningThreshold triggers a warning when channel utilization exceeds this percentage
// Default: 80
ChannelFullWarningThreshold int
}
RuntimeConfig contains configuration options for creating a runtime
func DefaultRuntimeConfig ¶ added in v0.3.0
func DefaultRuntimeConfig() *RuntimeConfig
DefaultRuntimeConfig returns a RuntimeConfig with sensible defaults
type RuntimeOption ¶ added in v0.3.0
type RuntimeOption func(*RuntimeConfig)
RuntimeOption is a functional option for configuring a runtime
func WithAgentStartTimeout ¶ added in v0.3.0
func WithAgentStartTimeout(timeout time.Duration) RuntimeOption
WithAgentStartTimeout sets the timeout for waiting for agents to become ready
func WithChannelBufferSize ¶ added in v0.3.0
func WithChannelBufferSize(size int) RuntimeOption
WithChannelBufferSize sets the channel buffer size
func WithMaxConcurrentCalls ¶ added in v0.3.0
func WithMaxConcurrentCalls(max int) RuntimeOption
WithMaxConcurrentCalls sets the maximum number of concurrent agent calls
func WithMetrics ¶ added in v0.3.0
func WithMetrics(enabled bool) RuntimeOption
WithMetrics enables or disables metrics collection
func WithSendTimeout ¶ added in v0.3.0
func WithSendTimeout(timeout time.Duration) RuntimeOption
WithSendTimeout sets the timeout for Send operations
func WithTracing ¶ added in v0.3.0
func WithTracing(enabled bool) RuntimeOption
WithTracing enables or disables OpenTelemetry tracing
type SessionConfig ¶ added in v0.3.0
type SessionConfig struct {
// Enabled determines whether sessions are active.
// Default: true (sessions are enabled by default).
Enabled bool `yaml:"enabled"`
// Store specifies the storage backend type.
// Options: "file", "firestore", "postgres"
// Default: "file"
Store string `yaml:"store"`
// BaseDir is the base directory for file-based storage.
// Default: ~/.aixgo/sessions
BaseDir string `yaml:"base_dir"`
// Checkpoint contains checkpoint configuration.
Checkpoint CheckpointConfig `yaml:"checkpoint,omitempty"`
}
SessionConfig configures session persistence.
type SupervisorDef ¶
type SupervisorDef struct {
Name string `yaml:"name"`
Model string `yaml:"model"`
MaxRounds int `yaml:"max_rounds,omitempty"`
}
SupervisorDef represents supervisor configuration
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent provides the public interfaces for building agents with Aixgo.
|
Package agent provides the public interfaces for building agents with Aixgo. |
|
cmd
|
|
|
benchmark
command
|
|
|
deploy/cloudrun
command
|
|
|
deploy/k8s
command
|
|
|
orchestrator
command
|
|
|
tools/generate-proto
command
|
|
|
deploy
|
|
|
cloudrun
command
deploy.go - Deploy aixgo to Google Cloud Run Run with: go run deploy.go
|
deploy.go - Deploy aixgo to Google Cloud Run Run with: go run deploy.go |
|
aggregator-workflow
command
|
|
|
classifier-workflow
command
|
|
|
huggingface-mcp
command
|
|
|
parallel-research
command
|
|
|
rag-agent
command
|
|
|
rag-documentation
command
|
|
|
reflection-code-generation
command
|
|
|
router-cost-optimization
command
|
|
|
session-basic
command
Package main demonstrates basic session usage with Aixgo agents.
|
Package main demonstrates basic session usage with Aixgo agents. |
|
session-react
command
Package main demonstrates session-aware ReAct agent usage with Aixgo.
|
Package main demonstrates session-aware ReAct agent usage with Aixgo. |
|
internal
|
|
|
graph
Package graph provides dependency graph operations for agent startup ordering.
|
Package graph provides dependency graph operations for agent startup ordering. |
|
pkg
|
|
|
security
Package security provides security utilities for the aixgo framework.
|
Package security provides security utilities for the aixgo framework. |
|
session
Package session provides session persistence for Aixgo agents.
|
Package session provides session persistence for Aixgo agents. |
|
tests
|
|