aixgo

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 23 Imported by: 0

README

aixgo

Go Version License Go Report Card

Production-grade AI agent framework for Go. Build secure, scalable multi-agent systems without Python dependencies.

Documentation | Quick Start | Features | Examples | Contributing

Why Aixgo?

Python AI frameworks excel at prototyping but struggle in production. Aixgo is built for systems that ship, scale, and stay running.

Dimension Python Frameworks Aixgo
Deployment 1GB+ containers <20MB binary
Cold Start 10-45 seconds <100ms
Type Safety Runtime errors Compile-time checks
Concurrency GIL limitations True parallelism
Scaling Manual queues/services Built-in channels → gRPC
Key Features
  • 6 Agent Types - ReAct, Classifier, Aggregator, Planner, Producer, Logger
  • 13 Orchestration Patterns - All production-proven patterns implemented
  • 6+ LLM Providers - OpenAI, Anthropic, Gemini, xAI, Vertex AI, HuggingFace, plus local inference
  • Session Persistence - Built-in conversation memory with JSONL and Redis storage (v0.3.0+)
  • Enterprise Security - 4 auth modes, RBAC, rate limiting, SSRF protection, comprehensive hardening
  • Full Observability - OpenTelemetry, Prometheus, Langfuse, cost tracking
  • Cost Optimization - 25-50% savings with Router pattern, 70% token reduction with RAG

📖 Complete Feature Catalog: See docs/FEATURES.md for all features with code references and technical details.

What's New in v0.3.0

Session Persistence - AI agents now remember conversations with built-in session management:

// Sessions are automatic - agents remember context
sess, _ := mgr.GetOrCreate(ctx, "assistant", "user-123")
result, _ := rt.CallWithSession(ctx, "assistant", msg, sess.ID())

Runtime Consolidation - Unified API with functional options:

rt := aixgo.NewRuntime(
    aixgo.WithSessionManager(sessionMgr),
    aixgo.WithMetrics(metricsCollector),
)

Distributed Runtime Parity - TLS/mTLS, streaming, and Redis sessions for multi-node deployments.

Security Hardening - 29 code scanning alerts fixed including path traversal, subprocess injection, and safe integer conversions.

Read the full release notes: v0.3.0 Release Blog Post

Quick Start

Installation

Choose the installation method based on your use case:

As a Library

For adding Aixgo to your Go project:

go get github.com/aixgo-dev/aixgo

This downloads only the Go framework source code (~2MB), not the website or documentation.

CLI Binary

The aixgo CLI runs agents from YAML configuration files.

Option 1: Install via go install (requires Go 1.26+):

go install github.com/aixgo-dev/aixgo/cmd/aixgo@latest

Option 2: Download pre-built binaries:

Download platform-specific binaries from GitHub Releases:

# Linux/macOS
curl -L https://github.com/aixgo-dev/aixgo/releases/latest/download/aixgo_Linux_x86_64.tar.gz | tar xz
sudo mv aixgo /usr/local/bin/

Available for Linux, macOS, and Windows (amd64, arm64).

Full Repository (Contributors)

For contributing or exploring examples:

git clone https://github.com/aixgo-dev/aixgo.git
cd aixgo
go build ./...

This includes the full repository with website source (web/), examples, and documentation.

What You Get
User Type Command What's Included Size
Library user go get github.com/aixgo-dev/aixgo Go source code only ~2MB
CLI user go install or binary download Single executable binary <20MB
Contributor git clone Full repo including web/, examples/, docs/ ~20MB
Setup

Before running your agents, you need to configure API keys for LLM providers. Create a .env file in your project root (or set environment variables):

# Copy the example environment file
cp .env.example .env

# Edit .env and add your API keys
# Required: At least one of these API keys
export OPENAI_API_KEY=sk-...        # For GPT models
export XAI_API_KEY=xai-...          # For Grok models
export ANTHROPIC_API_KEY=sk-ant-... # For Claude models (optional)
export HUGGINGFACE_API_KEY=hf_...  # For HuggingFace models (optional)

The framework will automatically detect the appropriate API key based on your model name:

  • grok-* or xai-* models use XAI_API_KEY
  • gpt-* models use OPENAI_API_KEY
  • claude-* models use ANTHROPIC_API_KEY
  • HuggingFace models (e.g., meta-llama/*) use HUGGINGFACE_API_KEY
Your First Agent

Create a simple multi-agent system in under 5 minutes:

1. Create a configuration file (config/agents.yaml):

supervisor:
  name: coordinator
  model: gpt-4-turbo
  max_rounds: 10

agents:
  - name: data-producer
    role: producer
    interval: 1s
    outputs:
      - target: analyzer

  - name: analyzer
    role: react
    model: gpt-4-turbo
    prompt: |
      You are a data analyst. Analyze incoming data and provide insights.
    inputs:
      - source: data-producer
    outputs:
      - target: logger

  - name: logger
    role: logger
    inputs:
      - source: analyzer

2. Create your main.go:

package main

import (
    "github.com/aixgo-dev/aixgo"
    _ "github.com/aixgo-dev/aixgo/agents"
)

func main() {
    if err := aixgo.Run("config/agents.yaml"); err != nil {
        panic(err)
    }
}

3. Run your agent system:

go run main.go

That's it! You now have a running multi-agent system with producer, analyzer, and logger agents orchestrated by a supervisor.

Use Cases

  • Data Pipelines - Add AI enrichment to high-throughput ETL workflows
  • API Services - Production AI endpoints with Go's performance
  • Edge Deployment - Run AI agents on resource-constrained devices
  • Multi-Agent Systems - Coordinate complex workflows with supervisor patterns

Architecture

Aixgo provides a flexible, layered architecture:

  • Agent Layer - 6 specialized agent types
  • Orchestration Layer - 13 production-proven patterns
  • Runtime Layer - Local (Go channels) or Distributed (gRPC)
  • Integration Layer - 6+ LLM providers, MCP tool calling, vector stores
  • Observability Layer - OpenTelemetry, Prometheus, cost tracking

🔗 Deep Dive: For detailed architecture and pattern documentation, see docs/PATTERNS.md.

Documentation

Comprehensive guides and examples available at aixgo.dev

Resources
  • Website - Comprehensive guides and documentation
  • docs/ - Technical reference documentation
  • examples/ - Production-ready code examples
  • web/ - Website source code
Core Documentation
Examples

Browse 15+ production-ready examples in examples/:

  • Agent types: ReAct, Classifier, Aggregator, Planner
  • LLM providers: OpenAI, Anthropic, Gemini, xAI, HuggingFace
  • Orchestration: MapReduce, parallel, sequential, reflection
  • Security: Authentication, authorization, TLS
  • Complete use cases: End-to-end applications

Development

# Build
git clone https://github.com/aixgo-dev/aixgo.git
cd aixgo
go build ./...

# Test
go test ./...
go test -race ./...

# Coverage
go test -cover ./...

See docs/CONTRIBUTING.md for contribution guidelines.

Contributing

We welcome contributions! See docs/CONTRIBUTING.md for guidelines.

Community

License

MIT License - see LICENSE for details.


Production-grade AI agents in pure Go.

Build AI agents that ship with the same performance, security, and operational simplicity as the rest of your Go stack.

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 Run

func Run(configPath string) error

Run starts the aixgo agent system from a config file

func RunWithConfig

func RunWithConfig(config *Config) error

RunWithConfig starts the aixgo agent system with the provided config

func RunWithConfigAndRuntime

func RunWithConfigAndRuntime(config *Config, rt agent.Runtime) error

RunWithConfigAndRuntime starts the system with a custom runtime (useful for testing)

func RunWithMCP

func RunWithMCP(configPath string, servers ...*mcp.Server) error

RunWithMCP starts the aixgo agent system with optional MCP servers

func StartAgents

func StartAgents(agents map[string]agent.Agent, agentDefs []agent.AgentDef, rt agent.Runtime) error

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

type FileReader interface {
	ReadFile(path string) ([]byte, error)
}

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) Reset

func (m *MockFileReader) Reset()

Reset clears all files and errors

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 OSFileReader

type OSFileReader struct{}

OSFileReader implements FileReader using os.ReadFile

func (*OSFileReader) ReadFile

func (r *OSFileReader) ReadFile(path string) ([]byte, error)

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

func (r *Runtime) Broadcast(msg *agent.Message) error

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) Get added in v0.3.0

func (r *Runtime) Get(name string) (agent.Agent, error)

Get retrieves a registered agent by name

func (*Runtime) GetChannelStats added in v0.3.0

func (r *Runtime) GetChannelStats(name string) (capacity, length int, err error)

GetChannelStats returns statistics for a channel. Returns capacity, current length, and an error if the channel doesn't exist.

func (*Runtime) List added in v0.3.0

func (r *Runtime) List() []string

List returns all registered agent names

func (*Runtime) MessagesSent added in v0.3.0

func (r *Runtime) MessagesSent() uint64

MessagesSent returns the total number of messages sent via Send().

func (*Runtime) Recv added in v0.3.0

func (r *Runtime) Recv(source string) (<-chan *agent.Message, error)

Recv returns a channel to receive messages from a source agent. If the source channel doesn't exist, it will be created.

func (*Runtime) Register added in v0.3.0

func (r *Runtime) Register(a agent.Agent) error

Register registers an agent with the runtime

func (*Runtime) Send added in v0.3.0

func (r *Runtime) Send(target string, msg *agent.Message) error

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

func (r *Runtime) SessionManager() session.Manager

SessionManager returns the session manager, if configured.

func (*Runtime) SetSessionManager added in v0.3.0

func (r *Runtime) SetSessionManager(sm session.Manager)

SetSessionManager sets the session manager for the runtime. This enables session-aware agent calls via CallWithSession.

func (*Runtime) Start added in v0.3.0

func (r *Runtime) Start(ctx context.Context) error

Start starts the runtime. Must be called before Call, CallParallel, or StartAgentsPhased.

func (*Runtime) StartAgentsPhased added in v0.3.0

func (r *Runtime) StartAgentsPhased(ctx context.Context, agentDefs map[string]agent.AgentDef) error

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

func (r *Runtime) Stop(ctx context.Context) error

Stop gracefully shuts down the runtime. All agents are stopped and all channels are closed.

func (*Runtime) Unregister added in v0.3.0

func (r *Runtime) Unregister(name string) error

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
aixgo 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
huggingface-mcp command
rag-agent 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.
llm
pkg
llm
mcp
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.
mcp
tests
e2e

Jump to

Keyboard shortcuts

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