Documentation
¶
Overview ¶
Package agents provides the agent system for AI-powered assistants. An agent is a persistent entity defined by system prompt, tools, and a swappable model. This follows patterns from pi-agent and clawdbot for agent definition and execution.
Index ¶
- Constants
- Variables
- func BuildSubagentSystemPrompt(params SubagentPromptParams) string
- func BuildSystemPrompt(params SystemPromptParams) string
- func EnsureBootstrapFiles(ctx context.Context, store *textfs.Store) (bool, error)
- func IdentityHasValues(identity IdentityFile) bool
- func IsBeeperHelp(agentID string) bool
- func IsBossAgent(agentID string) bool
- func IsHeartbeatContentEffectivelyEmpty(content string) bool
- func IsNexusAI(agentID string) bool
- func IsPreset(agentID string) bool
- func ResolveHeartbeatPrompt(raw string) string
- func StripHeartbeatTokenWithMode(text string, mode StripHeartbeatMode, maxAckChars int) (bool, string, bool)
- type AgentDefinition
- type AgentStore
- type ElevatedInfo
- type EmbeddedContextFile
- type Identity
- type IdentityFile
- type MemorySearchBatchConfig
- type MemorySearchCacheConfig
- type MemorySearchChunkingConfig
- type MemorySearchConfig
- type MemorySearchExperimentalConfig
- type MemorySearchHybridConfig
- type MemorySearchQueryConfig
- type MemorySearchRemoteConfig
- type MemorySearchSessionSyncConfig
- type MemorySearchStoreConfig
- type MemorySearchSyncConfig
- type MemorySearchVectorConfig
- type ModelConfig
- type ModelInfo
- type PromptMode
- type ReactionGuidance
- type ResolvedTimeFormat
- type ResponseMode
- type RuntimeInfo
- type SandboxInfo
- type SoulEvilCheckParams
- type SoulEvilConfig
- type SoulEvilDecision
- type SoulEvilPurge
- type StripHeartbeatMode
- type SubagentConfig
- type SubagentPromptParams
- type SystemPromptParams
- type TrimBootstrapResult
- type WorkspaceBootstrapFile
Constants ¶
const ( ModelClaudeSonnet = "anthropic/claude-sonnet-4.5" ModelClaudeOpus = "anthropic/claude-opus-4.6" ModelOpenAIGPT52 = "openai/gpt-5.2" ModelZAIGLM47 = "z-ai/glm-4.7" )
Model constants for preset agents (aligned with clawdbot recommended models).
const ( DefaultAgentsFilename = "AGENTS.md" DefaultSoulFilename = "SOUL.md" DefaultToolsFilename = "TOOLS.md" DefaultIdentityFilename = "IDENTITY.md" DefaultUserFilename = "USER.md" DefaultHeartbeatFilename = "HEARTBEAT.md" DefaultBootstrapFilename = "BOOTSTRAP.md" DefaultMemoryFilename = "MEMORY.md" DefaultMemoryAltFilename = "memory.md" )
const BeeperDelegationPrompt = `` /* 507-byte string literal not displayed */
const BeeperHelpPrompt = `` /* 478-byte string literal not displayed */
BeeperHelpPrompt is the system prompt for the Beeper Help agent.
const BeeperSearchPrompt = `` /* 269-byte string literal not displayed */
BeeperSearchPrompt is the system prompt for the Beeper Search agent.
const BossSystemPrompt = `` /* 1496-byte string literal not displayed */
BossSystemPrompt is the system prompt for the Boss agent.
const DefaultAgentAvatarMXC = "mxc://beeper.com/51a668657dd9e0132cc823ad9402c6c2d0fc3321"
BeeperAIAgent is the default agent for all new chats. It provides a simple, clean AI experience with sensible defaults.
const DefaultAgentID = "beeper"
DefaultAgentID is the ID of the default agent for new chats.
const (
DefaultBootstrapMaxChars = 20_000
)
const DefaultHeartbeatEvery = "30m"
DefaultHeartbeatEvery is the default heartbeat interval (OpenClaw).
const DefaultHeartbeatPrompt = "" /* 170-byte string literal not displayed */
DefaultHeartbeatPrompt is the OpenClaw default heartbeat prompt.
const DefaultMaxAckChars = 300
DefaultMaxAckChars is the max length for heartbeat acknowledgements (OpenClaw uses 300).
const DefaultSoulEvilFilename = "SOUL_EVIL.md"
const DefaultSystemPrompt = `You are a personal assistant called Beep. You run inside the Beeper app.`
DefaultSystemPrompt is the default prompt for general-purpose agents.
const HeartbeatToken = "HEARTBEAT_OK"
HeartbeatToken is the expected response for heartbeat polls.
const NexusSystemPrompt = `` /* 480-byte string literal not displayed */
NexusSystemPrompt is a concise, tool-grounded prompt for the Clay assistant.
const SilentReplyToken = "NO_REPLY"
SilentReplyToken is the expected response when the agent has nothing to say.
Variables ¶
var ( ErrMissingAgentID = errors.New("agent ID is required") ErrMissingAgentName = errors.New("agent name is required") ErrAgentNotFound = errors.New("agent not found") ErrAgentIsPreset = errors.New("cannot modify preset agent") )
Agent-related errors.
var BeeperAIAgent = &AgentDefinition{ ID: "beeper", Name: "Beep", Description: "Your AI assistant", AvatarURL: DefaultAgentAvatarMXC, Model: ModelConfig{ Primary: ModelClaudeOpus, Fallbacks: []string{ ModelClaudeSonnet, ModelOpenAIGPT52, ModelZAIGLM47, }, }, Tools: &toolpolicy.ToolPolicyConfig{Profile: toolpolicy.ProfileFull}, Subagents: &SubagentConfig{ AllowAgents: []string{"nexus"}, }, SystemPrompt: BeeperDelegationPrompt, PromptMode: PromptModeFull, IsPreset: true, CreatedAt: 0, UpdatedAt: 0, }
var BeeperHelpAgent = &AgentDefinition{ ID: "beeper_help", Name: "Beeper Help", Description: "Beeper help and feedback assistant", AvatarURL: DefaultAgentAvatarMXC, Model: ModelConfig{ Primary: ModelClaudeSonnet, Fallbacks: []string{ModelClaudeOpus}, }, Tools: &toolpolicy.ToolPolicyConfig{ Allow: []string{ toolspec.BeeperDocsName, toolspec.BeeperSendFeedbackName, toolspec.SessionStatusName, }, }, SystemPrompt: BeeperHelpPrompt, PromptMode: PromptModeFull, IsPreset: true, }
BeeperHelpAgent is a preset agent for Beeper help and feedback.
var BeeperSearchAgent = &AgentDefinition{ ID: "beeper_search", Name: "Beeper Search", Description: "Research assistant with web search enabled", Model: ModelConfig{ Primary: ModelOpenAIGPT52, Fallbacks: []string{ ModelClaudeSonnet, ModelClaudeOpus, }, }, Tools: &toolpolicy.ToolPolicyConfig{ Profile: toolpolicy.ProfileFull, Deny: []string{toolspec.WebSearchName}, }, SystemPrompt: BeeperSearchPrompt, PromptMode: PromptModeFull, IsPreset: true, CreatedAt: 0, UpdatedAt: 0, }
BeeperSearchAgent is a preset agent optimized for web research.
var BossAgent = &AgentDefinition{ ID: "boss", Name: "Meta Chatter", Description: "Manages agents, rooms, and system configuration", Model: ModelConfig{ Primary: ModelClaudeOpus, Fallbacks: []string{ ModelClaudeSonnet, ModelOpenAIGPT52, ModelZAIGLM47, }, }, Tools: &toolpolicy.ToolPolicyConfig{Profile: toolpolicy.ProfileBoss}, SystemPrompt: BossSystemPrompt, PromptMode: PromptModeFull, IsPreset: true, CreatedAt: 0, UpdatedAt: 0, }
BossAgent is the special agent that manages other agents and rooms. This is the "Meta Chatter" - uses Claude Opus with medium thinking.
var NexusAIAgent = &AgentDefinition{ ID: "nexus", Name: "Bexus", Description: "Clay relationship assistant", AvatarURL: DefaultAgentAvatarMXC, Model: ModelConfig{ Primary: ModelOpenAIGPT52, Fallbacks: []string{ ModelClaudeSonnet, ModelClaudeOpus, ModelZAIGLM47, }, }, Tools: &toolpolicy.ToolPolicyConfig{ Allow: append([]string{}, nexusToolAllowlist...), }, SystemPrompt: NexusSystemPrompt, PromptMode: PromptModeFull, IsPreset: true, CreatedAt: 0, UpdatedAt: 0, }
NexusAIAgent is a preset agent configured for Clay relationship workflows.
var PlaygroundAgent = &AgentDefinition{ ID: "playground", Name: "Model Playground", Description: "Direct model access with minimal tools, no agent personality", Model: ModelConfig{ Primary: ModelClaudeSonnet, Fallbacks: []string{ ModelOpenAIGPT52, ModelZAIGLM47, }, }, Tools: &toolpolicy.ToolPolicyConfig{Profile: toolpolicy.ProfileMinimal}, PromptMode: PromptModeNone, ResponseMode: ResponseModeRaw, IsPreset: true, CreatedAt: 0, UpdatedAt: 0, }
PlaygroundAgent is a sandbox for direct model access with minimal tools. This is for advanced users who want raw model interaction without agent personality.
var PresetAgents = []*AgentDefinition{ BeeperAIAgent, BeeperSearchAgent, BeeperHelpAgent, NexusAIAgent, PlaygroundAgent, }
PresetAgents contains the default agent definitions. Includes Beep (default), Playground (sandbox), and Boss (meta).
Functions ¶
func BuildSubagentSystemPrompt ¶
func BuildSubagentSystemPrompt(params SubagentPromptParams) string
BuildSubagentSystemPrompt creates a system prompt for spawned subagents. Matches OpenClaw's buildSubagentSystemPrompt from subagent-announce.ts.
func BuildSystemPrompt ¶
func BuildSystemPrompt(params SystemPromptParams) string
BuildSystemPrompt assembles the complete prompt from params. Matches OpenClaw's buildAgentSystemPrompt.
func EnsureBootstrapFiles ¶
EnsureBootstrapFiles ensures the default workspace files exist in the virtual FS. Returns true if this looks like a brand-new workspace.
func IdentityHasValues ¶
func IdentityHasValues(identity IdentityFile) bool
IdentityHasValues returns true if any identity fields are set.
func IsBeeperHelp ¶
IsBeeperHelp checks if an agent ID is the Beeper Help agent.
func IsBossAgent ¶
IsBossAgent checks if an agent ID is the Boss agent.
func IsHeartbeatContentEffectivelyEmpty ¶
IsHeartbeatContentEffectivelyEmpty checks if HEARTBEAT.md has actionable content. Returns false when content is empty/missing so the LLM can decide.
func ResolveHeartbeatPrompt ¶
ResolveHeartbeatPrompt returns the configured prompt or the default.
func StripHeartbeatTokenWithMode ¶
func StripHeartbeatTokenWithMode(text string, mode StripHeartbeatMode, maxAckChars int) (bool, string, bool)
StripHeartbeatTokenWithMode strips HEARTBEAT_OK from edges, honoring heartbeat-specific behavior. Returns (shouldSkip, strippedText, didStrip).
Types ¶
type AgentDefinition ¶
type AgentDefinition struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
// Model selection (like pi-agent)
Model ModelConfig `json:"model"`
// System prompt (base, sections added dynamically)
SystemPrompt string `json:"system_prompt,omitempty"`
PromptMode PromptMode `json:"prompt_mode,omitempty"` // full, minimal, none
// Tool policy (OpenClaw-style)
Tools *toolpolicy.ToolPolicyConfig `json:"tools,omitempty"`
// Subagent defaults (OpenClaw-style)
Subagents *SubagentConfig `json:"subagents,omitempty"`
// Agent behavior
Temperature float64 `json:"temperature,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"` // none, low, medium, high
ResponseMode ResponseMode `json:"response_mode,omitempty"` // natural (OpenClaw-style), raw (pass-through)
Identity *Identity `json:"identity,omitempty"` // custom identity for prompt
HeartbeatPrompt string `json:"heartbeat_prompt,omitempty"` // prompt for heartbeat polling (clawdbot parity)
// Memory search configuration override (OpenClaw-style)
MemorySearch *MemorySearchConfig `json:"memory_search,omitempty"`
// Metadata
IsPreset bool `json:"is_preset,omitempty"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
AgentDefinition is the persistent agent configuration.
func GetBeeperAI ¶
func GetBeeperAI() *AgentDefinition
GetBeeperAI returns a copy of the default Beep agent.
func GetBossAgent ¶
func GetBossAgent() *AgentDefinition
GetBossAgent returns a copy of the Boss agent definition.
func GetPresetByID ¶
func GetPresetByID(id string) *AgentDefinition
GetPresetByID returns a preset agent by ID.
func (*AgentDefinition) Clone ¶
func (a *AgentDefinition) Clone() *AgentDefinition
Clone creates a deep copy of the agent definition.
func (*AgentDefinition) EffectiveName ¶
func (a *AgentDefinition) EffectiveName() string
EffectiveName returns the agent's display name, preferring identity name over the base name.
func (*AgentDefinition) Validate ¶
func (a *AgentDefinition) Validate() error
Validate checks if the agent definition is valid.
type AgentStore ¶
type AgentStore interface {
// LoadAgents returns all agents for the current user.
LoadAgents(ctx context.Context) (map[string]*AgentDefinition, error)
// SaveAgent creates or updates an agent.
SaveAgent(ctx context.Context, agent *AgentDefinition) error
// DeleteAgent removes a custom agent.
DeleteAgent(ctx context.Context, agentID string) error
// ListModels returns available AI models.
ListModels(ctx context.Context) ([]ModelInfo, error)
// ListAvailableTools returns available tools.
ListAvailableTools(ctx context.Context) ([]tools.ToolInfo, error)
}
AgentStore interface for loading and saving agents. Implemented by the connector to store agents in Matrix state events.
type ElevatedInfo ¶
ElevatedInfo describes elevated tool availability.
type EmbeddedContextFile ¶
EmbeddedContextFile represents an injected project context file.
func BuildBootstrapContextFiles ¶
func BuildBootstrapContextFiles( files []WorkspaceBootstrapFile, maxChars int, warn func(message string), ) []EmbeddedContextFile
BuildBootstrapContextFiles prepares the injected context files for the system prompt.
type Identity ¶
type Identity struct {
Name string `json:"name,omitempty"`
Persona string `json:"persona,omitempty"`
}
Identity represents a custom agent persona.
type IdentityFile ¶
type IdentityFile struct {
Name string
Emoji string
Theme string
Creature string
Vibe string
Avatar string
}
IdentityFile represents values parsed from IDENTITY.md.
func ParseIdentityMarkdown ¶
func ParseIdentityMarkdown(content string) IdentityFile
ParseIdentityMarkdown extracts identity fields from IDENTITY.md content.
type MemorySearchBatchConfig ¶
type MemorySearchCacheConfig ¶
type MemorySearchConfig ¶
type MemorySearchConfig struct {
Enabled *bool `json:"enabled,omitempty"`
Sources []string `json:"sources,omitempty"`
ExtraPaths []string `json:"extra_paths,omitempty"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Remote *MemorySearchRemoteConfig `json:"remote,omitempty"`
Fallback string `json:"fallback,omitempty"`
Store *MemorySearchStoreConfig `json:"store,omitempty"`
Chunking *MemorySearchChunkingConfig `json:"chunking,omitempty"`
Sync *MemorySearchSyncConfig `json:"sync,omitempty"`
Query *MemorySearchQueryConfig `json:"query,omitempty"`
Cache *MemorySearchCacheConfig `json:"cache,omitempty"`
Experimental *MemorySearchExperimentalConfig `json:"experimental,omitempty"`
}
MemorySearchConfig configures semantic memory search (OpenClaw-style).
type MemorySearchExperimentalConfig ¶
type MemorySearchExperimentalConfig struct {
SessionMemory *bool `json:"session_memory,omitempty"`
}
type MemorySearchQueryConfig ¶
type MemorySearchQueryConfig struct {
MaxResults int `json:"max_results,omitempty"`
MinScore float64 `json:"min_score,omitempty"`
MaxInjectedChars int `json:"max_injected_chars,omitempty"`
Hybrid *MemorySearchHybridConfig `json:"hybrid,omitempty"`
}
type MemorySearchRemoteConfig ¶
type MemorySearchRemoteConfig struct {
BaseURL string `json:"base_url,omitempty"`
APIKey string `json:"api_key,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Batch *MemorySearchBatchConfig `json:"batch,omitempty"`
}
type MemorySearchStoreConfig ¶
type MemorySearchStoreConfig struct {
Driver string `json:"driver,omitempty"`
Path string `json:"path,omitempty"`
Vector *MemorySearchVectorConfig `json:"vector,omitempty"`
}
type MemorySearchSyncConfig ¶
type MemorySearchSyncConfig struct {
OnSessionStart *bool `json:"on_session_start,omitempty"`
OnSearch *bool `json:"on_search,omitempty"`
Watch *bool `json:"watch,omitempty"`
WatchDebounceMs int `json:"watch_debounce_ms,omitempty"`
IntervalMinutes int `json:"interval_minutes,omitempty"`
Sessions *MemorySearchSessionSyncConfig `json:"sessions,omitempty"`
}
type ModelConfig ¶
type ModelConfig struct {
Primary string `json:"primary"` // e.g., "anthropic/claude-sonnet-4.5"
Fallbacks []string `json:"fallbacks,omitempty"` // fallback chain
}
ModelConfig supports primary + fallback chain (like pi-agent).
func (ModelConfig) Clone ¶
func (m ModelConfig) Clone() ModelConfig
Clone creates a copy of the model config.
type ModelInfo ¶
type ModelInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Provider string `json:"provider,omitempty"`
Description string `json:"description,omitempty"`
// Capabilities
SupportsVision bool `json:"supports_vision,omitempty"`
SupportsTools bool `json:"supports_tools,omitempty"`
SupportsReasoning bool `json:"supports_reasoning,omitempty"`
SupportsStreaming bool `json:"supports_streaming,omitempty"`
SupportsCodeExecution bool `json:"supports_code_execution,omitempty"`
SupportsWebSearch bool `json:"supports_web_search,omitempty"`
// Limits
MaxContextTokens int `json:"max_context_tokens,omitempty"`
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"`
}
ModelInfo provides metadata about an available model.
type PromptMode ¶
type PromptMode string
PromptMode controls system prompt generation (like pi-agent).
const ( // PromptModeFull includes all sections in the system prompt. PromptModeFull PromptMode = "full" // PromptModeMinimal includes reduced sections for subagents. PromptModeMinimal PromptMode = "minimal" // PromptModeNone includes just identity, no additional sections. PromptModeNone PromptMode = "none" )
type ReactionGuidance ¶
type ReactionGuidance struct {
Level string // "minimal" or "extensive"
Channel string // e.g., "matrix", "signal"
}
ReactionGuidance controls reaction behavior in prompts. Matches OpenClaw's reactionGuidance with level and channel.
type ResolvedTimeFormat ¶
type ResolvedTimeFormat string
ResolvedTimeFormat mirrors OpenClaw's resolved time format type.
type ResponseMode ¶
type ResponseMode string
ResponseMode controls how LLM output is processed before delivery. Matches OpenClaw's behavior patterns.
const ( // ResponseModeNatural processes directives (reply tags, silent replies). // Reactions require the message tool. Matches OpenClaw behavior. ResponseModeNatural ResponseMode = "natural" // ResponseModeRaw passes LLM output directly to user without processing. ResponseModeRaw ResponseMode = "raw" )
type RuntimeInfo ¶
type RuntimeInfo struct {
AgentID string // Current agent ID
Host string // Hostname
OS string // Host OS
Arch string // Host architecture
Node string // Runtime version (OpenClaw uses Node)
Model string // Current model being used
DefaultModel string // Default model for the provider
Channel string // Communication channel
Capabilities []string // Runtime capabilities
RepoRoot string // Repo root path
}
RuntimeInfo contains runtime context for the LLM.
type SandboxInfo ¶
type SandboxInfo struct {
Enabled bool
WorkspaceDir string
WorkspaceAccess string // "none", "ro", "rw"
AgentWorkspaceMount string
BrowserBridgeURL string
BrowserNoVncURL string
HostBrowserAllowed *bool
Elevated *ElevatedInfo
}
SandboxInfo describes the current sandbox environment.
type SoulEvilCheckParams ¶
type SoulEvilCheckParams struct {
Config *SoulEvilConfig
UserTimezone string
Now time.Time
Random func() float64
}
type SoulEvilConfig ¶
type SoulEvilConfig struct {
File string `yaml:"file" json:"file,omitempty"`
Chance float64 `yaml:"chance" json:"chance,omitempty"`
Purge *SoulEvilPurge `yaml:"purge" json:"purge,omitempty"`
}
SoulEvilConfig controls persona swapping behavior.
type SoulEvilDecision ¶
func DecideSoulEvil ¶
func DecideSoulEvil(params SoulEvilCheckParams) SoulEvilDecision
DecideSoulEvil decides whether to swap SOUL content for this run.
type SoulEvilPurge ¶
type SoulEvilPurge struct {
At string `yaml:"at" json:"at,omitempty"`
Duration string `yaml:"duration" json:"duration,omitempty"`
}
SoulEvilPurge defines a daily purge window.
type StripHeartbeatMode ¶
type StripHeartbeatMode string
StripHeartbeatMode controls heartbeat token stripping behavior.
const ( StripHeartbeatModeHeartbeat StripHeartbeatMode = "heartbeat" StripHeartbeatModeMessage StripHeartbeatMode = "message" )
type SubagentConfig ¶
type SubagentConfig struct {
Model string `json:"model,omitempty"`
Thinking string `json:"thinking,omitempty"`
AllowAgents []string `json:"allowAgents,omitempty"`
}
SubagentConfig configures default subagent behavior for an agent.
type SubagentPromptParams ¶
type SubagentPromptParams struct {
RequesterSessionKey string // Session key of the agent that spawned this subagent
RequesterChannel string // Channel the requester is on (e.g., "matrix", "signal")
ChildSessionKey string // Session key of this subagent
Label string // Optional label for the task
Task string // Description of the task to complete
}
SubagentPromptParams contains inputs for building a subagent system prompt. Matches OpenClaw's buildSubagentSystemPrompt from subagent-announce.ts.
type SystemPromptParams ¶
type SystemPromptParams struct {
WorkspaceDir string
DefaultThinkLevel string
ReasoningLevel string
ExtraSystemPrompt string
OwnerNumbers []string
ReasoningTagHint bool
ToolNames []string
ToolSummaries map[string]string
ModelAliasLines []string
UserTimezone string
UserTime string
UserTimeFormat ResolvedTimeFormat
ContextFiles []EmbeddedContextFile
SkillsPrompt string
HeartbeatPrompt string
WorkspaceNotes []string
TTSHint string
PromptMode PromptMode
RuntimeInfo *RuntimeInfo
MessageToolHints []string
SandboxInfo *SandboxInfo
ReactionGuidance *ReactionGuidance
MemoryCitations string
UserIdentitySupplement string
}
SystemPromptParams contains all inputs for building a system prompt. This matches OpenClaw's buildAgentSystemPrompt params.
type TrimBootstrapResult ¶
func TrimBootstrapContent ¶
func TrimBootstrapContent(content, fileName string, maxChars int) TrimBootstrapResult
TrimBootstrapContent trims a file's content to the configured max chars.
type WorkspaceBootstrapFile ¶
WorkspaceBootstrapFile represents a bootstrapped workspace file.
func FilterBootstrapFilesForSession ¶
func FilterBootstrapFilesForSession(files []WorkspaceBootstrapFile, isSubagent bool) []WorkspaceBootstrapFile
FilterBootstrapFilesForSession filters bootstrap files for subagent sessions.
func LoadBootstrapFiles ¶
LoadBootstrapFiles loads the default workspace files from the virtual FS.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package tools provides the tool system for AI agents.
|
Package tools provides the tool system for AI agents. |