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 LLMEvaluatorPolicy
- type Options
- type OutputGuardrails
- type QueryType
- type RegexBlocklistPolicy
- 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
CodeChain *chain.UtcpChainClient
AllowUnsafeTools bool
Guardrails *OutputGuardrails
// 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.
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 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
CodeChain *chain.UtcpChainClient
AllowUnsafeTools bool
Guardrails *OutputGuardrails
}
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 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 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_cron
command
|
|
|
example/checkpoint
command
|
|
|
example/codemode
command
|
|
|
example/codemode_utcp_workflow
command
|
|
|
example/composability
command
|
|
|
example/guardrails
command
|
|
|
src
|
|