Documentation
¶
Index ¶
- type Agent
- func (a *Agent) AsTool(name, description string) Tool
- func (a *Agent) AsUTCPTool(name, description string) tools.Tool
- func (a *Agent) Checkpoint() ([]byte, error)
- func (a *Agent) EnsureSpaceGrants(sessionID string, spaces []string)
- func (a *Agent) Flush(ctx context.Context, sessionID string) error
- func (a *Agent) Generate(ctx context.Context, sessionID, userInput string) (any, error)
- func (a *Agent) GenerateStream(ctx context.Context, sessionID, userInput string) (<-chan models.StreamChunk, error)
- func (a *Agent) GenerateWithFiles(ctx context.Context, sessionID string, userInput string, files []models.File) (string, error)
- func (a *Agent) RegisterAsUTCPProvider(ctx context.Context, client utcp.UtcpClientInterface, name, description string) error
- func (a *Agent) Restore(data []byte) error
- func (a *Agent) RetrieveAttachmentFiles(ctx context.Context, sessionID string, limit int) ([]models.File, error)
- func (agent *Agent) Save(ctx context.Context, role, content string)
- func (a *Agent) SessionMemory() *memory.SessionMemory
- func (a *Agent) SetSharedSpaces(shared *memory.SharedSession)
- func (a *Agent) SubAgents() []SubAgent
- func (a *Agent) ToolSpecs() []tools.Tool
- func (a *Agent) Tools() []Tool
- type AgentState
- type AgentToolAdapter
- type FormatEnforcer
- type InputGuardrails
- type InputSafetyPolicy
- type InputTransformer
- type LLMEvaluatorInputPolicy
- type LLMEvaluatorPolicy
- type Options
- type OutputGuardrails
- type PIIMaskerTransformer
- type PromptInjectionDetectorPolicy
- type QueryType
- type RegexBlocklistPolicy
- type RegexInputBlocklistPolicy
- type RegexInputReplaceTransformer
- type SafetyPolicy
- type StaticSubAgentDirectory
- type StaticToolCatalog
- type SubAgent
- type SubAgentDirectory
- type SubAgentTool
- type Tool
- type ToolCatalog
- type ToolChoice
- type ToolRequest
- type ToolResponse
- type ToolSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
UTCPClient utcp.UtcpClientInterface
CodeMode *codemode.CodeModeUTCP
AllowUnsafeTools bool
Guardrails *OutputGuardrails
InputGuardrails *InputGuardrails
// contains filtered or unexported fields
}
Agent orchestrates model calls, memory, tools, and sub-agents.
func (*Agent) AsUTCPTool ¶ added in v1.10.0
AsUTCPTool exposes the agent as a UTCP tool with an in-process handler. The tool accepts: - instruction (required): user query for the agent - session_id (optional): custom session id; defaults to a namespaced value derived from the tool name
func (*Agent) Checkpoint ¶ added in v1.10.3
Checkpoint serializes the agent's current state (system prompt and short-term memory) to a byte slice. This can be saved to disk or a database to pause the agent.
func (*Agent) EnsureSpaceGrants ¶
EnsureSpaceGrants gives the provided sessionID writer access to each space. This mirrors how tests set up spaces: mem.Spaces.Grant(space, session, role, ttl).
func (*Agent) GenerateStream ¶ added in v1.10.6
func (a *Agent) GenerateStream(ctx context.Context, sessionID, userInput string) (<-chan models.StreamChunk, error)
GenerateStream provides a streaming interface for the agent's generation process. It follows the same logic as Generate but returns a channel of chunks.
func (*Agent) GenerateWithFiles ¶
func (a *Agent) GenerateWithFiles( ctx context.Context, sessionID string, userInput string, files []models.File, ) (string, error)
GenerateWithFiles sends the user message plus in-memory files to the model without ingesting them into long-term memory. Use this when you already have file bytes (e.g., uploaded via API) and want the model to consider them ephemerally for this turn only. GenerateWithFiles runs the full orchestration pipeline (direct tool → subagent → CodeMode → UTCP tool loop) before falling back to a file-aware model call. Files are forwarded to the planner so tools can be selected with attachment context, but tool execution still uses the normal UTCP arguments.
func (*Agent) RegisterAsUTCPProvider ¶ added in v1.10.0
func (a *Agent) RegisterAsUTCPProvider(ctx context.Context, client utcp.UtcpClientInterface, name, description string) error
RegisterAsUTCPProvider registers the agent as a UTCP tool on the provided client. It installs a lightweight in-process transport under the "text" provider type to route CallTool invocations directly to the agent's Generate method.
func (*Agent) Restore ¶ added in v1.10.3
Restore rehydrates the agent's state from a checkpoint. It restores the system prompt and short-term memory.
func (*Agent) RetrieveAttachmentFiles ¶
func (a *Agent) RetrieveAttachmentFiles(ctx context.Context, sessionID string, limit int) ([]models.File, error)
RetrieveAttachmentFiles returns attachment files stored for the session. It reconstructs the original bytes from base64-encoded metadata, making it suitable for binary assets such as images and videos.
func (*Agent) Save ¶
Save stores a conversation turn into all shared spaces. role should be "user" or "agent".
func (*Agent) SessionMemory ¶
func (a *Agent) SessionMemory() *memory.SessionMemory
SessionMemory exposes the underlying session memory (useful for advanced setup/tests).
func (*Agent) SetSharedSpaces ¶
func (a *Agent) SetSharedSpaces(shared *memory.SharedSession)
type AgentState ¶ added in v1.10.3
type AgentState struct {
SystemPrompt string `json:"system_prompt"`
ShortTerm map[string][]model.MemoryRecord `json:"short_term"`
JoinedSpaces []string `json:"joined_spaces,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
AgentState represents the serializable state of an agent for checkpointing.
type AgentToolAdapter ¶ added in v1.0.9
type AgentToolAdapter struct {
// contains filtered or unexported fields
}
AgentToolAdapter adapts an Agent to the Tool interface.
func (*AgentToolAdapter) Invoke ¶ added in v1.0.9
func (t *AgentToolAdapter) Invoke(ctx context.Context, req ToolRequest) (ToolResponse, error)
func (*AgentToolAdapter) Spec ¶ added in v1.0.9
func (t *AgentToolAdapter) Spec() ToolSpec
type FormatEnforcer ¶ added in v1.11.0
FormatEnforcer defines an interface for validating or repairing the format of LLM responses.
type InputGuardrails ¶ added in v1.11.4
type InputGuardrails struct {
SafetyPolicies []InputSafetyPolicy
Transformers []InputTransformer
}
InputGuardrails holds the input safety policies and transformers.
func (*InputGuardrails) ValidateAndTransform ¶ added in v1.11.4
ValidateAndTransform applies safety checks and transformers to the input.
type InputSafetyPolicy ¶ added in v1.11.4
InputSafetyPolicy defines an interface for validating LLM inputs.
type InputTransformer ¶ added in v1.11.4
InputTransformer defines an interface for modifying or sanitizing LLM inputs.
type LLMEvaluatorInputPolicy ¶ added in v1.11.4
type LLMEvaluatorInputPolicy struct {
// contains filtered or unexported fields
}
LLMEvaluatorInputPolicy uses a secondary language model to evaluate the safety of the proposed input query.
func NewLLMEvaluatorInputPolicy ¶ added in v1.11.4
func NewLLMEvaluatorInputPolicy(model models.Agent, promptTemplate string) *LLMEvaluatorInputPolicy
NewLLMEvaluatorInputPolicy creates a new input safety policy that uses an LLM to evaluate inputs. If promptTemplate is empty, a default evaluation prompt is used.
type LLMEvaluatorPolicy ¶ added in v1.11.1
type LLMEvaluatorPolicy struct {
// contains filtered or unexported fields
}
LLMEvaluatorPolicy uses a secondary language model to evaluate the safety of the proposed response.
func NewLLMEvaluatorPolicy ¶ added in v1.11.1
func NewLLMEvaluatorPolicy(model models.Agent, promptTemplate string) *LLMEvaluatorPolicy
NewLLMEvaluatorPolicy creates a new safety policy that uses an LLM to evaluate responses. If promptTemplate is empty, a default evaluation prompt is used.
type Options ¶
type Options struct {
Model models.Agent
Memory *memory.SessionMemory
SystemPrompt string
ContextLimit int
Tools []Tool
SubAgents []SubAgent
ToolCatalog ToolCatalog
SubAgentDirectory SubAgentDirectory
UTCPClient utcp.UtcpClientInterface
CodeMode *codemode.CodeModeUTCP
AllowUnsafeTools bool
Guardrails *OutputGuardrails
InputGuardrails *InputGuardrails
}
Options configure a new Agent.
type OutputGuardrails ¶ added in v1.11.0
type OutputGuardrails struct {
SafetyPolicies []SafetyPolicy
FormatEnforcers []FormatEnforcer
}
OutputGuardrails holds the policy engines and formatting rules.
func (*OutputGuardrails) ValidateAndRepair ¶ added in v1.11.0
ValidateAndRepair applies safety checks and format enforcing to the response.
type PIIMaskerTransformer ¶ added in v1.11.4
type PIIMaskerTransformer struct {
// contains filtered or unexported fields
}
PIIMaskerTransformer automatically detects personal data and replaces it with generic descriptors like [EMAIL] or [PHONE].
func NewPIIMaskerTransformer ¶ added in v1.11.4
func NewPIIMaskerTransformer(maskEmail, maskPhone, maskSSN, maskCards bool) *PIIMaskerTransformer
NewPIIMaskerTransformer creates a new PII masker transformer configuring the categories to mask.
type PromptInjectionDetectorPolicy ¶ added in v1.11.4
type PromptInjectionDetectorPolicy struct {
// contains filtered or unexported fields
}
PromptInjectionDetectorPolicy scans the user query for common phrases associated with prompt injection attacks (heuristics).
func NewPromptInjectionDetectorPolicy ¶ added in v1.11.4
func NewPromptInjectionDetectorPolicy(customPatterns []string) *PromptInjectionDetectorPolicy
NewPromptInjectionDetectorPolicy creates a new injection detector policy. If customPatterns is provided, they are converted to lowercase and appended to the default patterns list.
type RegexBlocklistPolicy ¶ added in v1.11.1
type RegexBlocklistPolicy struct {
// contains filtered or unexported fields
}
RegexBlocklistPolicy enforces that a configurable list of regular expressions are not matched within the LLM output.
func NewRegexBlocklistPolicy ¶ added in v1.11.1
func NewRegexBlocklistPolicy(patterns []string) (*RegexBlocklistPolicy, error)
NewRegexBlocklistPolicy creates a new policy with the given string regex patterns. It returns an error if any of the patterns fail to compile.
type RegexInputBlocklistPolicy ¶ added in v1.11.4
type RegexInputBlocklistPolicy struct {
// contains filtered or unexported fields
}
RegexInputBlocklistPolicy validates that the input does not match a configurable list of regular expression patterns.
func NewRegexInputBlocklistPolicy ¶ added in v1.11.4
func NewRegexInputBlocklistPolicy(patterns []string) (*RegexInputBlocklistPolicy, error)
NewRegexInputBlocklistPolicy creates a new policy with the given string regex patterns. It returns an error if any of the patterns fail to compile.
type RegexInputReplaceTransformer ¶ added in v1.11.4
type RegexInputReplaceTransformer struct {
// contains filtered or unexported fields
}
RegexInputReplaceTransformer replaces occurrences of a regular expression pattern with a specified replacement string.
func NewRegexInputReplaceTransformer ¶ added in v1.11.4
func NewRegexInputReplaceTransformer(pattern string, replacement string) (*RegexInputReplaceTransformer, error)
NewRegexInputReplaceTransformer creates a new regex replace transformer.
type SafetyPolicy ¶ added in v1.11.0
SafetyPolicy defines an interface for validating LLM responses.
type StaticSubAgentDirectory ¶
type StaticSubAgentDirectory struct {
// contains filtered or unexported fields
}
StaticSubAgentDirectory is the default SubAgentDirectory implementation.
func NewStaticSubAgentDirectory ¶
func NewStaticSubAgentDirectory(subagents []SubAgent) *StaticSubAgentDirectory
NewStaticSubAgentDirectory constructs a directory from the provided sub-agents.
func (*StaticSubAgentDirectory) All ¶
func (d *StaticSubAgentDirectory) All() []SubAgent
All returns the registered sub-agents in registration order.
func (*StaticSubAgentDirectory) Lookup ¶
func (d *StaticSubAgentDirectory) Lookup(name string) (SubAgent, bool)
Lookup retrieves a sub-agent by name.
func (*StaticSubAgentDirectory) Register ¶
func (d *StaticSubAgentDirectory) Register(subAgent SubAgent) error
Register adds a sub-agent to the directory. Duplicate names return an error.
type StaticToolCatalog ¶
type StaticToolCatalog struct {
// contains filtered or unexported fields
}
StaticToolCatalog is the default in-memory implementation of ToolCatalog used by the runtime.
func NewStaticToolCatalog ¶
func NewStaticToolCatalog(tools []Tool) *StaticToolCatalog
NewStaticToolCatalog constructs a catalog seeded with the provided tools.
func (*StaticToolCatalog) Lookup ¶
func (c *StaticToolCatalog) Lookup(name string) (Tool, ToolSpec, bool)
Lookup returns the tool and its specification if present.
func (*StaticToolCatalog) Register ¶
func (c *StaticToolCatalog) Register(tool Tool) error
Register adds a tool to the catalog using a lower-cased key. Duplicate names return an error.
func (*StaticToolCatalog) Specs ¶
func (c *StaticToolCatalog) Specs() []ToolSpec
Specs returns a snapshot of the tool specifications in registration order.
func (*StaticToolCatalog) Tools ¶
func (c *StaticToolCatalog) Tools() []Tool
Tools returns the registered tools in order.
type SubAgent ¶
type SubAgent interface {
Name() string
Description() string
Run(ctx context.Context, input string) (string, error)
}
SubAgent represents a specialist agent that can be delegated work.
type SubAgentDirectory ¶
type SubAgentDirectory interface {
Register(subAgent SubAgent) error
Lookup(name string) (SubAgent, bool)
All() []SubAgent
}
SubAgentDirectory stores sub-agents by name while preserving insertion order.
type SubAgentTool ¶ added in v1.0.9
type SubAgentTool struct {
// contains filtered or unexported fields
}
SubAgentTool adapts a SubAgent to the Tool interface.
func (*SubAgentTool) Invoke ¶ added in v1.0.9
func (t *SubAgentTool) Invoke(ctx context.Context, req ToolRequest) (ToolResponse, error)
func (*SubAgentTool) Spec ¶ added in v1.0.9
func (t *SubAgentTool) Spec() ToolSpec
type Tool ¶
type Tool interface {
Spec() ToolSpec
Invoke(ctx context.Context, req ToolRequest) (ToolResponse, error)
}
Tool exposes structured metadata and an invocation handler.
func NewAgentTool ¶ added in v1.0.9
NewAgentTool creates a new tool that wraps an Agent.
func NewSubAgentTool ¶ added in v1.0.9
NewSubAgentTool creates a new tool that wraps a SubAgent.
type ToolCatalog ¶
type ToolCatalog interface {
Register(tool Tool) error
Lookup(name string) (Tool, ToolSpec, bool)
Specs() []ToolSpec
Tools() []Tool
}
ToolCatalog maintains an ordered set of tools and provides lookup by name.
type ToolChoice ¶ added in v0.7.5
type ToolRequest ¶
ToolRequest captures an invocation request for a tool.
type ToolResponse ¶
ToolResponse represents the structured response returned by a tool.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
app
command
main.go — fixed agent-mode with provider flag Runs your Agent with optional file context using GenerateWithFiles.
|
main.go — fixed agent-mode with provider flag Runs your Agent with optional file context using GenerateWithFiles. |
|
codemode
command
|
|
|
example
command
main.go — fixed agent-mode with provider flag, Postgres memory + CreateSchema Runs your Agent with optional file context using GenerateWithFiles.
|
main.go — fixed agent-mode with provider flag, Postgres memory + CreateSchema Runs your Agent with optional file context using GenerateWithFiles. |
|
example/agent_as_tool
command
|
|
|
example/agent_as_utcp_codemode
command
|
|
|
example/autonomous_agent
command
|
|
|
example/autonomous_cron
command
|
|
|
example/checkpoint
command
|
|
|
example/claw_cron
command
|
|
|
example/codemode
command
|
|
|
example/codemode_utcp_workflow
command
|
|
|
example/composability
command
|
|
|
example/graph_workflow
command
|
|
|
example/guardrails
command
|
|
|
example/internal/filestore
Package filestore provides the lightweight JSON-backed memory used by the autonomous examples.
|
Package filestore provides the lightweight JSON-backed memory used by the autonomous examples. |
|
gateway
command
cmd/gateway — HTTP gateway that exposes a go-agent as a REST API.
|
cmd/gateway — HTTP gateway that exposes a go-agent as a REST API. |
|
src
|
|