Documentation
¶
Overview ¶
Package agent provides the agent definition and builder API.
Index ¶
- Variables
- func ApplyDefaults(cfg, defaults *AgentConfig)
- func BuildAll(ctx context.Context, fc *FileConfig, opts ...BuildOption) (map[string]*Agent, error)
- func BuildProvider(cfg ModelConfig) (model.Provider, error)
- func CompressToolCalls(messages []model.Message, maxCalls int) []model.Message
- func DurableGraphs(fc *FileConfig, agents map[string]*Agent) map[string]*graph.CompiledGraph
- func ExtractReasoningParts(content string) map[string]string
- func NormalizeFileConfig(fc *FileConfig)
- func ReadStoredResult(ctx context.Context, store storage.Storage, sessionID, key string) (string, error)
- type Agent
- func (a *Agent) Chat(ctx context.Context, userMessage string) (*model.ChatResponse, error)
- func (a *Agent) ChatStream(ctx context.Context, userMessage string) (<-chan *model.ChatResponse, error)
- func (a *Agent) ChatWithSession(ctx context.Context, sessionID, userMessage string) (*model.ChatResponse, error)
- func (a *Agent) CloseMCP()
- func (a *Agent) ConnectMCP(ctx context.Context) error
- func (a *Agent) Execute(ctx context.Context, task string) (string, error)
- func (a *Agent) Resume(ctx context.Context, sessionID string) (*graph.RunState, error)
- func (a *Agent) Run(ctx context.Context, input map[string]any) (*graph.RunState, error)
- type AgentConfig
- type BuildOption
- type Builder
- func (b *Builder) AddCapability(capability string) *Builder
- func (b *Builder) AddExample(input, output string) *Builder
- func (b *Builder) AddHook(h hooks.Hook) *Builder
- func (b *Builder) AddInputGuardrail(name string, g guardrails.Guardrail) *Builder
- func (b *Builder) AddInstruction(instruction string) *Builder
- func (b *Builder) AddMCPServer(cfg mcp.ServerConfig) *Builder
- func (b *Builder) AddOutputGuardrail(name string, g guardrails.Guardrail) *Builder
- func (b *Builder) AddSkill(s *skill.Skill) *Builder
- func (b *Builder) AddSubAgent(sub *Agent) *Builder
- func (b *Builder) AddTool(def *tool.Definition) *Builder
- func (b *Builder) AddToolkit(tk *tool.Toolkit) *Builder
- func (b *Builder) Build() (*Agent, error)
- func (b *Builder) Description(d string) *Builder
- func (b *Builder) WithBroker(br *stream.Broker) *Builder
- func (b *Builder) WithContextConfig(cfg ContextConfig) *Builder
- func (b *Builder) WithContextPins(fn func(ctx context.Context) []model.Message) *Builder
- func (b *Builder) WithDebug(debug bool) *Builder
- func (b *Builder) WithGraph(g *graph.StateGraph) *Builder
- func (b *Builder) WithHistoryRuns(n int) *Builder
- func (b *Builder) WithInstructionsFn(fn func(ctx context.Context, state map[string]any) []string) *Builder
- func (b *Builder) WithKnowledge(k knowledge.Knowledge) *Builder
- func (b *Builder) WithMaxIterations(n int) *Builder
- func (b *Builder) WithMemory(m *memory.Store) *Builder
- func (b *Builder) WithMemoryManager(m *memory.Manager) *Builder
- func (b *Builder) WithMemoryRecall(cfg RecallConfig) *Builder
- func (b *Builder) WithModel(p model.Provider) *Builder
- func (b *Builder) WithOutputSchema(s map[string]any) *Builder
- func (b *Builder) WithReasoning(strategy ReasoningStrategy) *Builder
- func (b *Builder) WithReasoningConfig(cfg model.ReasoningConfig) *Builder
- func (b *Builder) WithReasoningModel(p model.Provider) *Builder
- func (b *Builder) WithStorage(s storage.Storage) *Builder
- func (b *Builder) WithStreaming(enabled bool) *Builder
- func (b *Builder) WithSystemPrompt(prompt string) *Builder
- func (b *Builder) WithTracer(t *chronostrace.Collector) *Builder
- func (b *Builder) WithUserID(id string) *Builder
- type ChatSession
- type ContextConfig
- type ContextYAML
- type DeploymentConfig
- type EdgeConfig
- type EvictionResult
- type Example
- type FileConfig
- type GraphConfig
- type ModelConfig
- type NodeConfig
- type ReasoningStrategy
- type ReasoningYAML
- type RecallConfig
- type SandboxConfig
- type SkillConfig
- type StorageConfig
- type TeamConfig
- type ToolConfig
- type ToolHandlerFactory
Constants ¶
This section is empty.
Variables ¶
var ErrConfigNotFound = errors.New("no agent config found")
ErrConfigNotFound indicates no agent config file could be located — as opposed to a config file that exists but fails to parse or validate. Callers that treat "no config" as an acceptable default (e.g. `chronos serve`, which starts fine with zero registered agents) should check for this specifically with errors.Is rather than swallowing every LoadFile error identically; a malformed or invalid file should still fail startup.
Functions ¶
func ApplyDefaults ¶ added in v0.12.1
func ApplyDefaults(cfg, defaults *AgentConfig)
ApplyDefaults fills in every zero-valued field on cfg from defaults. It is used internally by LoadFile and re-exported for callers (like the deploy CLI) that unmarshal their own wrapper config and still need the same per-field override behavior — provider, endpoint, deployment, api_version, storage, system prompt, streaming, reasoning, and so on.
func BuildAll ¶
func BuildAll(ctx context.Context, fc *FileConfig, opts ...BuildOption) (map[string]*Agent, error)
BuildAll constructs all agents from a FileConfig. BuildOptions (e.g. WithToolHandler) apply to every agent built.
func BuildProvider ¶ added in v0.10.0
func BuildProvider(cfg ModelConfig) (model.Provider, error)
BuildProvider constructs a model.Provider from a ModelConfig. It is the exported entry point used by callers outside this package (e.g. the CLI wiring a team's router_model) that need the same provider resolution as agent construction.
func CompressToolCalls ¶ added in v0.3.0
CompressToolCalls removes older tool call/result pairs from message history, keeping only the most recent maxCalls pairs. System messages and non-tool messages are always preserved.
func DurableGraphs ¶ added in v0.13.0
func DurableGraphs(fc *FileConfig, agents map[string]*Agent) map[string]*graph.CompiledGraph
DurableGraphs returns the compiled graph.CompiledGraph for every agent in fc marked `durable: true`, keyed by agent id, from an already-built agents map (e.g. the result of BuildAll). An agent absent from agents, or whose Graph did not get compiled, is skipped rather than causing a panic — both are defensive only (BuildAll either builds every agent in fc and compiles every declared graph, or returns an error), so callers driving `chronos serve`-style registration (cli/cmd/serve.go, examples/ yaml_dashboard) can share this instead of each hand-rolling the loop with their own (potentially missing) nil checks.
func ExtractReasoningParts ¶ added in v0.3.0
ExtractReasoningParts parses a reflection-style response into components.
func NormalizeFileConfig ¶ added in v0.12.1
func NormalizeFileConfig(fc *FileConfig)
NormalizeFileConfig applies the standard post-parse pipeline to a FileConfig: backward-compatible alias resolution (`system` <- `system_prompt` legacy), per-agent default merging via ApplyDefaults, and ${ENV} expansion across every string field on every agent and every team's router model. LoadFile runs it internally; callers that unmarshal their own YAML wrapper (like the deploy CLI, which adds a `sandbox:` block on top of FileConfig) should call it before building agents so the two entry points cannot drift apart.
Types ¶
type Agent ¶
type Agent struct {
ID string
Name string
Description string
UserID string
// Core components
Model model.Provider
Tools *tool.Registry
Skills *skill.Registry
Memory *memory.Store
Storage storage.Storage
Graph *graph.CompiledGraph
// Enhancements
Knowledge knowledge.Knowledge
MemoryManager *memory.Manager
Hooks hooks.Chain
Guardrails *guardrails.Engine
Broker *stream.Broker // SSE broker for real-time event streaming
Tracer *chronostrace.Collector // execution tracer for span-based observability
SessionState map[string]any // persistent cross-turn state
OutputSchema map[string]any // JSON Schema for structured output
NumHistoryRuns int // number of past runs to inject into context
ContextCfg ContextConfig // context window management and summarization
MemoryRecall RecallConfig // automatic semantic long-term recall policy
// ContextPinsFn supplies dynamic pinned context evaluated fresh on every
// turn. Like ContextConfig.PinnedMessages, its output is injected as system
// context and is never summarized or evicted by compaction — but because it
// runs per turn it can reflect live state (e.g. the current task plan). It is
// the decoupled seam the deep-agent preset (WC-A-005) uses to keep the active
// plan pinned without the SDK depending on the planning toolkit.
ContextPinsFn func(ctx context.Context) []model.Message
// System prompt and instructions
SystemPrompt string
Instructions []string
InstructionsFn func(ctx context.Context, state map[string]any) []string
Examples []Example
// Reasoning and iteration control
Reasoning ReasoningStrategy
ReasoningConfig model.ReasoningConfig // provider-native reasoning/thinking settings
ReasoningModel model.Provider // separate, more capable model for reasoning steps
Debug bool // when set, logs detailed execution info
MaxIterations int // max tool-calling loop iterations; 0 = default (25)
Stream bool // preferred CLI response mode
StreamConfigured bool // distinguishes an explicit YAML value from the default
// MCP servers
MCPClients []*mcp.Client
// Multi-agent
SubAgents []*Agent
MaxConcurrentSubAgents int
Capabilities []string // advertised capabilities for the protocol bus
}
Agent is the top-level agent definition.
func BuildAgent ¶
func BuildAgent(ctx context.Context, cfg *AgentConfig, opts ...BuildOption) (*Agent, error)
BuildAgent constructs a fully-wired *Agent from an AgentConfig.
func (*Agent) Chat ¶
Chat sends a single user message to the agent's model and returns the response. This is a convenience method for agents that have a model but no graph.
func (*Agent) ChatStream ¶ added in v0.7.0
func (a *Agent) ChatStream(ctx context.Context, userMessage string) (<-chan *model.ChatResponse, error)
ChatStream sends a single user message and streams the model's response token by token. It returns a channel of *model.ChatResponse that the caller must drain to completion; the channel is closed when the turn finishes.
Channel protocol:
- Delta chunks have Delta == true and carry a Content fragment to print.
- Exactly one final chunk has Delta == false with the aggregated Usage and StopReason (and empty Content, since the text was already streamed).
- A chunk with Err != nil signals a fatal error; it is the last chunk.
Tool calls are handled transparently: when the model requests tools, the fragments are aggregated, the tools are executed, and the follow-up turn is streamed — so callers see live text across every round.
Note on guardrails/schema: because tokens are emitted as they arrive, output guardrails and OutputSchema are validated only AFTER the full response has been streamed. A validation failure surfaces as a trailing Err chunk, by which point the (rejected) text has already been shown. Use the blocking Chat when you need pre-emission validation.
func (*Agent) ChatWithSession ¶
func (a *Agent) ChatWithSession(ctx context.Context, sessionID, userMessage string) (*model.ChatResponse, error)
ChatWithSession sends a message within a persistent, multi-turn session. When the conversation approaches the model's context window limit, older messages are automatically summarized to stay within budget.
func (*Agent) CloseMCP ¶ added in v0.3.0
func (a *Agent) CloseMCP()
CloseMCP disconnects all MCP server connections.
func (*Agent) ConnectMCP ¶ added in v0.3.0
ConnectMCP connects all configured MCP servers and registers their tools in the agent's tool registry. Call after Build.
func (*Agent) Execute ¶
Execute runs the agent on a text task and returns the text response. Unlike Run, Execute works with just a model — no graph or storage needed. This is the primary entry point for team-based orchestration where agents are lightweight task executors.
type AgentConfig ¶
type AgentConfig struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Description string `yaml:"description,omitempty"`
UserID string `yaml:"user_id,omitempty"`
Model ModelConfig `yaml:"model"`
Storage StorageConfig `yaml:"storage,omitempty"`
System string `yaml:"system_prompt,omitempty"`
SystemLegacy string `yaml:"system,omitempty"` // backward-compatible alias
Instructions []string `yaml:"instructions,omitempty"`
Tools []ToolConfig `yaml:"tools,omitempty"`
Capabilities []string `yaml:"capabilities,omitempty"`
// MCPServers lists Model Context Protocol servers whose tools are
// registered with the agent when ConnectMCP is called after Build.
MCPServers []mcp.ServerConfig `yaml:"mcp_servers,omitempty"`
// Skills lists reusable capability bundles this agent advertises. Each
// skill is registered in the agent's skill.Registry, and its Description
// (plus any Markdown body loaded from ManifestPath) is appended to the
// system prompt at Build time so the model knows the skill is available.
Skills []SkillConfig `yaml:"skills,omitempty"`
// UseSkills references skills by name from the file-level catalog loaded
// from FileConfig.SkillsDir (SKILL.md files). Referencing an unknown name
// aborts the build with a clear error.
UseSkills []string `yaml:"use_skills,omitempty"`
OutputSchema map[string]any `yaml:"output_schema,omitempty"`
NumHistoryRuns int `yaml:"num_history_runs,omitempty"`
Stream bool `yaml:"stream,omitempty"`
StreamConfigured bool `yaml:"-"`
Debug bool `yaml:"debug,omitempty"`
Tracing bool `yaml:"tracing,omitempty"`
PermissionMode tool.PermissionMode `yaml:"permission_mode,omitempty"`
Reasoning ReasoningYAML `yaml:"reasoning,omitempty"`
Context ContextYAML `yaml:"context,omitempty"`
// Team nesting: an agent config can reference sub-agents by ID
SubAgents []string `yaml:"sub_agents,omitempty"`
// Graph declares a durable multi-node graph for this agent (see
// graphbuild.go). When set, BuildAgent/BuildAll compile it and attach it
// to the built Agent exactly as Agent.WithGraph would, so Agent.Run
// automatically creates a session and checkpoints through it — no
// additional wiring required.
Graph *GraphConfig `yaml:"graph,omitempty"`
// Durable opts this agent's compiled graph into being registered with
// ChronosOS by `chronos serve`/`chronos deploy` (a dashboard.GraphRegistry
// entry keyed by ID), so its runs are visible/resumable/time-travelable
// from the dashboard. It does not itself change Agent.Run's behavior —
// any agent with a Graph already runs durably once Storage is configured;
// this flag only controls server-side exposure. Requires Graph to be set.
Durable bool `yaml:"durable,omitempty"`
}
AgentConfig is the YAML-serializable definition of a single agent.
type BuildOption ¶ added in v0.5.0
type BuildOption func(*buildOptions)
BuildOption configures BuildAgent/BuildAll. Options are applied per call, so nothing leaks between builds.
func WithBasePath ¶ added in v0.12.1
func WithBasePath(path string) BuildOption
WithBasePath roots the built-in file tools (file_read, file_write, file_list, file_glob, file_grep) at the given directory instead of the process working directory. An empty path leaves the "." default in place.
func WithPeerAgents ¶ added in v0.13.0
func WithPeerAgents(peers map[string]*Agent) BuildOption
WithPeerAgents seeds the build with already-built sibling agents that a `subagent`-type graph node (see graphbuild.go) may reference by ID. BuildAll fills this automatically from its own build set; pass it explicitly when driving BuildAgent directly with a graph that delegates to agents you built separately.
func WithSkillCatalog ¶ added in v0.12.1
func WithSkillCatalog(catalog map[string]*skill.Skill) BuildOption
WithSkillCatalog seeds the build with a set of pre-loaded skills that AgentConfig.UseSkills entries can reference by name. BuildAll fills this automatically from FileConfig.SkillsDir; passing it explicitly is useful when driving BuildAgent directly with a hand-built catalog.
func WithToolHandler ¶ added in v0.5.0
func WithToolHandler(name string, factory ToolHandlerFactory) BuildOption
WithToolHandler binds a config tool name to a factory that builds its runtime handler for this build. When the agent being built declares a custom tool whose name matches, the factory supplies the real handler. An empty name or nil factory is ignored. Pass it to BuildAgent/BuildAll:
agent.BuildAgent(ctx, cfg, agent.WithToolHandler("word_count", factory))
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder provides a fluent API for constructing agents.
func (*Builder) AddCapability ¶
func (*Builder) AddExample ¶ added in v0.3.0
func (*Builder) AddInputGuardrail ¶
func (b *Builder) AddInputGuardrail(name string, g guardrails.Guardrail) *Builder
func (*Builder) AddInstruction ¶
func (*Builder) AddMCPServer ¶ added in v0.3.0
func (b *Builder) AddMCPServer(cfg mcp.ServerConfig) *Builder
func (*Builder) AddOutputGuardrail ¶
func (b *Builder) AddOutputGuardrail(name string, g guardrails.Guardrail) *Builder
func (*Builder) AddSubAgent ¶
func (*Builder) AddToolkit ¶ added in v0.3.0
func (*Builder) Description ¶
func (*Builder) WithContextConfig ¶
func (b *Builder) WithContextConfig(cfg ContextConfig) *Builder
func (*Builder) WithContextPins ¶ added in v0.10.0
WithContextPins registers a function that supplies dynamic pinned context, evaluated fresh on every turn and always retained through compaction. See Agent.ContextPinsFn.
func (*Builder) WithHistoryRuns ¶
func (*Builder) WithInstructionsFn ¶ added in v0.3.0
func (*Builder) WithMaxIterations ¶ added in v0.3.0
func (*Builder) WithMemoryRecall ¶ added in v0.10.0
func (b *Builder) WithMemoryRecall(cfg RecallConfig) *Builder
func (*Builder) WithReasoning ¶ added in v0.3.0
func (b *Builder) WithReasoning(strategy ReasoningStrategy) *Builder
WithReasoning configures the agent's reasoning strategy.
func (*Builder) WithReasoningConfig ¶ added in v0.11.0
func (b *Builder) WithReasoningConfig(cfg model.ReasoningConfig) *Builder
func (*Builder) WithReasoningModel ¶ added in v0.3.0
func (*Builder) WithStreaming ¶ added in v0.11.0
func (*Builder) WithSystemPrompt ¶
func (*Builder) WithTracer ¶
func (b *Builder) WithTracer(t *chronostrace.Collector) *Builder
func (*Builder) WithUserID ¶
type ChatSession ¶
type ChatSession struct {
ID string `json:"id"`
AgentID string `json:"agent_id"`
Messages []model.Message `json:"messages"`
Summary string `json:"summary"`
// contains filtered or unexported fields
}
ChatSession manages multi-turn conversation state with automatic context-window summarization.
type ContextConfig ¶
type ContextConfig struct {
MaxContextTokens int `json:"max_context_tokens" yaml:"max_tokens"` // override model default; 0 = use model default
SummarizeThreshold float64 `json:"summarize_threshold" yaml:"summarize_threshold"` // fraction of context window to trigger summarization (default 0.8)
PreserveRecentTurns int `json:"preserve_recent_turns" yaml:"preserve_recent_turns"` // number of recent user/assistant pairs to keep (default 5)
MaxToolResultTokens int `json:"max_tool_result_tokens" yaml:"max_tool_result_tokens"` // max tokens for tool result before eviction (default 20000)
MaxToolCallsFromHistory int `json:"max_tool_calls_from_history" yaml:"max_tool_calls"` // max tool call pairs to keep in history
// PinnedMessages are injected as system context on every turn and are never
// summarized or evicted by compaction. Use them for content that must always
// be visible to the model (policies, invariants, a fixed brief). Set
// programmatically via the builder; there is no YAML surface for structured
// messages, so no yaml tag is advertised.
PinnedMessages []model.Message `json:"pinned_messages,omitempty"`
}
ContextConfig controls context window management and automatic summarization.
Automatic compaction (WC-A-004): when a session conversation approaches the model's context window, ChatWithSession summarizes older turns into a compact running summary and preserves only the most recent turns (see SummarizeThreshold and PreserveRecentTurns). PinnedMessages are always retained verbatim and are never summarized, so critical context — e.g. an operating contract or the active task plan (WC-A-001) — survives every compaction pass.
type ContextYAML ¶
type ContextYAML struct {
MaxTokens int `yaml:"max_tokens,omitempty"`
SummarizeThreshold float64 `yaml:"summarize_threshold,omitempty"`
PreserveRecentTurns int `yaml:"preserve_recent_turns,omitempty"`
}
ContextYAML is the YAML-serializable form of ContextConfig.
type DeploymentConfig ¶ added in v0.12.1
type DeploymentConfig struct {
Name string `yaml:"name,omitempty"`
Sandbox SandboxConfig `yaml:"sandbox,omitempty"`
}
DeploymentConfig is the `chronos deploy` metadata block on FileConfig.
type EdgeConfig ¶ added in v0.13.0
type EdgeConfig struct {
From string `yaml:"from"`
To string `yaml:"to,omitempty"`
Conditional bool `yaml:"conditional,omitempty"`
RouteKey string `yaml:"route_key,omitempty"`
Routes map[string]string `yaml:"routes,omitempty"`
Default string `yaml:"default,omitempty"`
}
EdgeConfig declares one graph edge. A static edge sets To; a conditional edge sets Conditional and routes on State[RouteKey] via Routes, falling back to Default when the looked-up value has no matching route.
type EvictionResult ¶ added in v0.3.0
type EvictionResult struct {
StorageKey string `json:"storage_key"`
Preview string `json:"preview"`
FullSize int `json:"full_size"`
}
EvictionResult holds the outcome of evicting a large tool result.
func EvictLargeResult ¶ added in v0.3.0
func EvictLargeResult(ctx context.Context, store storage.Storage, sessionID, toolName string, result any) (*EvictionResult, error)
EvictLargeResult stores a large tool result in storage and returns a truncated preview with a reference key. The agent can re-read the full result using the read_stored_result built-in tool.
type FileConfig ¶
type FileConfig struct {
Agents []AgentConfig `yaml:"agents"`
Teams []TeamConfig `yaml:"teams,omitempty"`
// Defaults applied to all agents unless overridden
Defaults *AgentConfig `yaml:"defaults,omitempty"`
// SkillsDir is a filesystem path (absolute, or relative to the YAML file's
// directory) that BuildAll walks at load time for SKILL.md files. Every
// discovered skill forms a catalog keyed by name; agents opt into catalog
// skills by listing their names under `use_skills:`.
SkillsDir string `yaml:"skills_dir,omitempty"`
// Deployment holds `chronos deploy`-only fields. Ignored by other commands.
Deployment *DeploymentConfig `yaml:"deployment,omitempty"`
// Deprecated: top-level `name:` — use `deployment.name` instead. Accepted
// for one release; NormalizeFileConfig promotes it into Deployment and
// prints a deprecation warning.
LegacyName string `yaml:"name,omitempty"`
// Deprecated: top-level `sandbox:` — use `deployment.sandbox` instead.
LegacySandbox *SandboxConfig `yaml:"sandbox,omitempty"`
}
FileConfig is the top-level structure of a Chronos YAML config file. Supports both a single agent and a list of agents, plus optional teams.
The optional Deployment block carries deployment-topology metadata (name, sandbox backend, work directory, image, resource caps). It is only consumed by `chronos deploy`; the `run`, `team run`, `repl`, and `serve` entry points ignore it, so the same YAML can back every command.
func LoadFile ¶
func LoadFile(path string) (*FileConfig, error)
LoadFile parses a YAML config file and returns all agent configs. Searches in order: given path, .chronos/agents.yaml, ~/.chronos/agents.yaml.
func (*FileConfig) FindAgent ¶
func (fc *FileConfig) FindAgent(idOrName string) (*AgentConfig, error)
FindAgent looks up an agent by ID or name (case-insensitive) within a FileConfig.
func (*FileConfig) FindTeam ¶
func (fc *FileConfig) FindTeam(id string) (*TeamConfig, error)
FindTeam looks up a team by ID (case-insensitive) within a FileConfig.
type GraphConfig ¶ added in v0.13.0
type GraphConfig struct {
Entry string `yaml:"entry"`
Finish string `yaml:"finish,omitempty"`
Nodes []NodeConfig `yaml:"nodes"`
Edges []EdgeConfig `yaml:"edges,omitempty"`
}
GraphConfig declares a durable multi-node graph in YAML. It compiles to a *graph.StateGraph the same shape a Go caller would build with graph.New(id).AddNode(...).AddEdge(...); see attachGraph.
type ModelConfig ¶
type ModelConfig struct {
Provider string `yaml:"provider"` // openai, anthropic, gemini, mistral, ollama, azure, groq, together, deepseek, openrouter, fireworks, perplexity, anyscale, compatible
Model string `yaml:"model,omitempty"` // model ID, e.g. "gpt-4o", "claude-sonnet-4-6"
APIKey string `yaml:"api_key,omitempty"` // literal or ${ENV_VAR}
BaseURL string `yaml:"base_url,omitempty"`
OrgID string `yaml:"org_id,omitempty"`
TimeoutSec int `yaml:"timeout_sec,omitempty"`
// Azure-specific
Endpoint string `yaml:"endpoint,omitempty"`
Deployment string `yaml:"deployment,omitempty"`
APIVersion string `yaml:"api_version,omitempty"`
}
ModelConfig describes which model provider and settings to use.
type NodeConfig ¶ added in v0.13.0
type NodeConfig struct {
ID string `yaml:"id"`
Type string `yaml:"type"`
Interrupt bool `yaml:"interrupt,omitempty"`
Prompt string `yaml:"prompt,omitempty"` // model
Tool string `yaml:"tool,omitempty"` // tool
Agent string `yaml:"agent,omitempty"` // subagent
InputKey string `yaml:"input_key,omitempty"` // tool, subagent
OutputKey string `yaml:"output_key,omitempty"` // model, tool, subagent
Set map[string]any `yaml:"set,omitempty"` // passthrough
}
NodeConfig declares one graph node. YAML cannot carry arbitrary Go code, so Type selects one of four declarative node kinds instead of a hand-written graph.NodeFunc:
- "model" calls the agent's configured provider with Prompt (a Go text/template rendered against {{.state.<key>}}) and writes the reply to OutputKey (default "response").
- "tool" calls a tool already registered on the agent (see AgentConfig.Tools) by name, passing State[InputKey] (or the whole state when InputKey is empty) as arguments and writing the result to OutputKey (default "<id>_result").
- "subagent" delegates to another AgentConfig in the same file by ID, calling its Chat with State[InputKey] (or State["message"] when InputKey is empty) and writing the reply to OutputKey (default "<id>_response").
- "passthrough" merges Set into State — the minimal building block for an Interrupt (HITL) gate that just needs to record a decision on resume.
type ReasoningStrategy ¶ added in v0.3.0
type ReasoningStrategy int
ReasoningStrategy defines the chain-of-thought approach.
const ( ReasoningNone ReasoningStrategy = iota ReasoningCoT // chain-of-thought: "Let's think step by step" ReasoningReflection // think, then critique )
type ReasoningYAML ¶ added in v0.11.0
type ReasoningYAML struct {
Strategy string `yaml:"strategy,omitempty"` // none, cot, reflection
Native bool `yaml:"native,omitempty"`
Effort string `yaml:"effort,omitempty"` // low, medium, high
BudgetTokens int `yaml:"budget_tokens,omitempty"`
Summary bool `yaml:"summary,omitempty"`
}
ReasoningYAML configures prompt-based and provider-native reasoning.
type RecallConfig ¶ added in v0.10.0
type RecallConfig struct {
Disabled bool `json:"disabled" yaml:"disabled"` // opt out of semantic recall
TopK int `json:"top_k" yaml:"top_k"` // memories to recall per turn; 0 = default 5
ScoreThreshold float32 `json:"score_threshold" yaml:"score_threshold"` // drop recalled memories below this score; 0 = keep all
}
RecallConfig controls automatic semantic long-term recall. Recall is enabled by default (zero value) and fires only when the agent has a MemoryManager with an attached vector index (see memory.Manager.WithVectorIndex); otherwise the agent falls back to the legacy full-memory dump, so existing agents are unaffected.
type SandboxConfig ¶ added in v0.12.1
type SandboxConfig struct {
Backend string `yaml:"backend,omitempty"` // process, container, k8s
WorkDir string `yaml:"work_dir,omitempty"`
Image string `yaml:"image,omitempty"`
Network string `yaml:"network,omitempty"`
Timeout string `yaml:"timeout,omitempty"` // e.g. "5m", "30s"
}
SandboxConfig configures the isolation boundary a deployment runs inside. It maps 1:1 to sandbox.Config; the CLI parses these values into the sandbox package's own types.
type SkillConfig ¶ added in v0.12.1
type SkillConfig struct {
Name string `yaml:"name"`
Version string `yaml:"version,omitempty"`
Description string `yaml:"description,omitempty"`
Author string `yaml:"author,omitempty"`
Tags []string `yaml:"tags,omitempty"`
Tools []string `yaml:"tools,omitempty"`
Manifest map[string]any `yaml:"manifest,omitempty"`
ManifestPath string `yaml:"manifest_path,omitempty"` // Markdown file appended to system prompt
}
SkillConfig declares a named capability bundle for an agent. Skills are descriptive: they advertise what the agent can do (and which tools it uses to do it), and their Description + optional Markdown body are injected into the system prompt at Build time. Skills do NOT register tools by themselves — list those under `tools:` or `mcp_servers:` as usual.
type StorageConfig ¶
type StorageConfig struct {
Backend string `yaml:"backend,omitempty"` // sqlite, postgres (default: sqlite)
DSN string `yaml:"dsn,omitempty"` // connection string or file path
// Connection-pool tuning for the SQL backends (sqlite, postgres). A zero
// value leaves the adapter's built-in default in place.
MaxOpenConns int `yaml:"max_open_conns,omitempty"`
MaxIdleConns int `yaml:"max_idle_conns,omitempty"`
ConnMaxLifetimeSec int `yaml:"conn_max_lifetime_sec,omitempty"`
}
StorageConfig describes the backing store.
type TeamConfig ¶
type TeamConfig struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Strategy string `yaml:"strategy"` // sequential, parallel, router, coordinator, swarm, hierarchy
Agents []string `yaml:"agents"` // agent IDs (order matters for sequential)
Coordinator string `yaml:"coordinator,omitempty"` // agent ID: coordinator (coordinator strategy) or root supervisor (hierarchy)
MaxConcurrency int `yaml:"max_concurrency,omitempty"` // for parallel strategy
MaxIterations int `yaml:"max_iterations,omitempty"` // for coordinator strategy
ErrorStrategy string `yaml:"error_strategy,omitempty"` // fail_fast, collect, best_effort
// Router selects how the router strategy picks an agent: "model" (default —
// an LLM reasons over agent descriptions) or "capability" (a zero-LLM
// heuristic that matches advertised capabilities against state keys).
Router string `yaml:"router,omitempty"`
// RouterModel optionally overrides which model drives model-based routing.
// When its Provider is empty, the router reuses the first member agent's
// model — set this to route with a cheaper/faster model than the workers.
RouterModel ModelConfig `yaml:"router_model,omitempty"`
// InitialAgent is the entry agent for the swarm strategy (defaults to the
// first listed agent).
InitialAgent string `yaml:"initial_agent,omitempty"`
// MaxHandoffs caps peer-to-peer handoffs in the swarm strategy (0 = default).
MaxHandoffs int `yaml:"max_handoffs,omitempty"`
}
TeamConfig defines a multi-agent team in YAML.
type ToolConfig ¶
type ToolConfig struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Parameters map[string]any `yaml:"parameters,omitempty"` // JSON Schema
Permission tool.Permission `yaml:"permission,omitempty"`
RequiresConfirmation *bool `yaml:"requires_confirmation,omitempty"`
RequiresUserInput *bool `yaml:"requires_user_input,omitempty"`
}
ToolConfig describes a tool to register on the agent.
type ToolHandlerFactory ¶ added in v0.5.0
type ToolHandlerFactory func(tc ToolConfig) (tool.Handler, error)
ToolHandlerFactory constructs the runtime handler for a config-declared custom tool. It receives the ToolConfig (name, description, JSON-Schema parameters) so the factory can honor the declared contract, and returns the tool.Handler that executes the tool. A non-nil error aborts agent build.
Bind a YAML tool name to a real handler by passing WithToolHandler to BuildAgent/BuildAll, so config-built agents execute working tools instead of no-op placeholders.