Agent Architecture
Agent interface, tool system, LLM routing, and runtime architecture.
Agent Architecture
Agent Interface
Every agent implements the core Agent interface:
type Agent interface {
// Name returns the agent's identifier
Name() string
// Reconcile converges actual state to desired state
Reconcile(ctx context.Context, desired, actual State) (*ExecutionPlan, error)
// Heal diagnoses and repairs an issue
Heal(ctx context.Context, issue Issue) (*ExecutionPlan, error)
// Plan generates a plan without executing it
Plan(ctx context.Context, desired, actual State) (*ExecutionPlan, error)
// Tools returns the agent's available tools
Tools() []Tool
}
ExecutionPlan
An execution plan is a sequence of steps the agent intends to perform:
type ExecutionPlan struct {
Steps []Step
RiskLevel RiskLevel
Reasoning string
}
type Step struct {
ToolName string
Parameters map[string]interface{}
Description string
RiskLevel RiskLevel
}
Tool System
Each tool has a name, description, typed parameters, risk level, and an execute function:
type Tool struct {
Name string
Description string
Parameters []Parameter
RiskLevel RiskLevel
Execute func(ctx context.Context, params map[string]interface{}) (interface{}, error)
}
type Parameter struct {
Name string
Type string
Description string
Required bool
}
Tools are registered with their agent at startup. The LLM selects which tools to use based on the task at hand. Each tool call is validated against its parameter schema before execution.
LLM Providers
The system supports multiple LLM providers:
| Provider | Models | Use Case |
|---|---|---|
| Anthropic | Claude 3.5 Sonnet, Claude 3 Opus | Primary reasoning and planning |
| OpenAI | GPT-4, GPT-4 Turbo | Alternative provider |
| Ollama | Llama, Mistral, CodeLlama | Local/air-gapped deployments |
The LLM Router selects the appropriate model based on task complexity:
| Complexity | Model Selection | Examples |
|---|---|---|
| Low | Small/fast model | Status checks, simple CRUD |
| Medium | Standard model | Single-resource provisioning |
| High | Large/capable model | Multi-resource planning, healing diagnosis |
The Agent Runtime is the host process for all agents:
- Initialization: Loads all agents and registers their tools
- Watch Loop: Subscribes to etcd key prefixes for state changes
- Dispatch: Routes state changes to the responsible agent
- Execution: Runs the agent's plan through the tool system
- State Update: Writes results back to etcd
The runtime handles concurrency, rate limiting, retries, and graceful shutdown.