Documentation
¶
Overview ¶
Package tagent provides the top-level composition root for tagent applications.
The root package encapsulates the agent instantiation process, assembling a TagentAgent with configured tools and wiring cross-boundary dependencies.
Tool Registration:
Built-in tools are registered via RegisterBuiltinTools() (see registry.go). External tools can be registered via RegisterPlainTool() and RegisterToolAgent(). Only tools that are both registered AND configured for an agent can be used.
This file contains factory functions for built-in plain tools.
Package tagent — ToolRegistry wraps the global tool registration maps from agent/tool_agent.go and provides a unified interface for:
- Registering built-in tools (exec + knowledge/recall sub-tools)
- Querying factories by ID
- Validating that config-referenced tools are registered
Package tagent provides the top-level composition root for tagent applications.
The root package encapsulates the agent instantiation process, assembling a TagentAgent with configured tools and wiring cross-boundary dependencies.
Dependency direction (all one-way, no cycles):
tagent (root) → agent → plugin → memory tagent (root) → tool/action → memory tagent (root) → tool/recall → memory tagent (root) → tool/knowledge → memory tagent (root) → prompt
Tool Registration:
tagent uses a ToolRegistry to manage available tools. Built-in tools are registered via RegisterBuiltinTools(). External tools can be registered via RegisterPlainTool() and RegisterToolAgent(). Only tools that are both registered and configured for an agent can be used by that agent.
Usage:
ta, err := tagent.New(tagent.DefaultConfig(),
tagent.WithModel(modelInstance),
)
testing.go provides exported helpers for integration tests in tests/. These expose internal APIs for comprehensive testing. Do NOT rely on them in production code — they may change without notice.
Convention: all symbols use the "Testing" prefix.
Index ¶
- Constants
- func DefaultPromptsFS() embed.FS
- func New(cfg Config, opts ...Option) (*agent.TagentAgent, error)
- func RegisterBuiltinTools() error
- func TestingBuildAgent(name string, acfg AgentConfig, cfg Config, m model.Model, ...) (*agent.TagentAgent, error)
- type AgentConfig
- type CompressConfig
- type Config
- type ExtraParam
- type LifecycleConfig
- type MeditationConfig
- type MemoryConfig
- type Option
- type PromptConfig
- type ProviderConfig
- type RemoteConfig
- type ToolKind
- type ToolRef
- type ToolRegistry
- func (r *ToolRegistry) GetPlainToolFactory(id string) (agent.PlainToolFactory, bool)
- func (r *ToolRegistry) GetToolAgentFactory(id string) (agent.ToolAgentFactory, bool)
- func (r *ToolRegistry) RegisterPlainTool(id string, factory agent.PlainToolFactory)
- func (r *ToolRegistry) RegisterToolAgent(id string, factory agent.ToolAgentFactory)
- func (r *ToolRegistry) ValidateToolAccess(cfg *Config) error
Constants ¶
const ( DefaultEntry = "tagent" DefaultPromptDir = "resources/prompts" DefaultMaxToolIter = 50 DefaultMaxTokens = 8000 DefaultTemperature = 0.7 DefaultCompressThresh = 0.8 DefaultAgentMaxToolIter = 10 DefaultAgentMaxTokens = 4096 DefaultAgentTemp = 0.3 )
Default values
const DefaultPromptsPrefix = "resources/prompts"
DefaultPromptsPrefix is the path prefix under which the embedded defaults live.
Variables ¶
This section is empty.
Functions ¶
func DefaultPromptsFS ¶
DefaultPromptsFS returns the embedded framework default prompts. The tree is rooted at "resources/prompts" (e.g. "resources/prompts/recall_tool_desc.md").
func New ¶
func New(cfg Config, opts ...Option) (*agent.TagentAgent, error)
New creates a fully-wired TagentAgent from declarative Config + runtime Options.
Config is declarative and serializable (loadable from YAML/JSON via LoadConfig). Options inject runtime-only dependencies (model instances, etc.).
New handles all cross-boundary wiring internally:
- Registers built-in tools (knowledge, recall, exec)
- Validates that all configured tools are registered
- Resolves the entry agent from Config.Agents map
- Creates a MemoryStore per agent (isolated, from MemoryConfig)
- Builds tools by resolving ToolRef entries (agent refs → sub-agents)
- For agent-kind tools: creates the referenced agent and wraps it via AgentToolWrapper which handles event_key → external context resolution
- For tool-kind tools: delegates to registered plain tool factories
func RegisterBuiltinTools ¶
func RegisterBuiltinTools() error
func TestingBuildAgent ¶
func TestingBuildAgent( name string, acfg AgentConfig, cfg Config, m model.Model, skillRepo tagenttool.SkillRepository, mcpToolSets []trpctool.ToolSet, loader *prompt.Loader, cache map[string]*agent.TagentAgent, ) (*agent.TagentAgent, error)
TestingBuildAgent creates a TagentAgent using the internal build pipeline. Test-only — do NOT use in production code.
Types ¶
type AgentConfig ¶
type AgentConfig struct {
// Model is the LLM model name (resolved at runtime). Falls back to Config.Model.
Model string `json:"model,omitempty" yaml:"model,omitempty"`
// Provider overrides the global default provider for this agent.
// References a key in Config.Providers. Falls back to Config.Provider if empty.
Provider string `json:"provider,omitempty" yaml:"provider,omitempty"`
// PromptDir is the base directory for this agent's prompt files.
// Falls back to Config.PromptDir.
PromptDir string `json:"prompt_dir,omitempty" yaml:"prompt_dir,omitempty"`
// SystemPrompt configures how to load this agent's system prompt.
SystemPrompt PromptConfig `json:"system_prompt,omitempty" yaml:"system_prompt,omitempty"`
// Memory configures this agent's own memory store.
// Each agent has its own isolated storage. Defaults to in-memory store.
Memory MemoryConfig `json:"memory,omitempty" yaml:"memory,omitempty"`
// Tools declares which tools this agent uses.
// Tools can reference other agents (agent kind) or plain tools (tool kind).
Tools []ToolRef `json:"tools" yaml:"tools"`
// Agent parameters
MaxToolIterations int `json:"max_tool_iterations,omitempty" yaml:"max_tool_iterations,omitempty"`
MaxTokens int `json:"max_tokens,omitempty" yaml:"max_tokens,omitempty"`
Temperature float64 `json:"temperature,omitempty" yaml:"temperature,omitempty"`
CompressThreshold float64 `json:"compress_threshold,omitempty" yaml:"compress_threshold,omitempty"`
KeepRecentTasks int `json:"keep_recent_tasks,omitempty" yaml:"keep_recent_tasks,omitempty"`
// TaskTerminalTTL is the grace period an exited task (completed/failed/
// cancelled/dead) is retained before pruning, as a duration string
// (e.g. "2m", "30m"). It bounds the resume_task window for terminal
// subagent tasks. Empty/invalid → default "2m".
TaskTerminalTTL string `json:"task_terminal_ttl,omitempty" yaml:"task_terminal_ttl,omitempty"`
// ResumeContextRounds caps how many prior rounds the subagent task-chain
// restorer injects on resume (default 3).
ResumeContextRounds int `json:"resume_context_rounds,omitempty" yaml:"resume_context_rounds,omitempty"`
Compress CompressConfig `json:"compress,omitempty" yaml:"compress,omitempty"`
// Generation controls thinking/reasoning mode for the LLM.
// When set, these fields are merged into model.GenerationConfig.
ThinkingEnabled *bool `json:"thinking_enabled,omitempty" yaml:"thinking_enabled,omitempty"`
ThinkingTokens *int `json:"thinking_tokens,omitempty" yaml:"thinking_tokens,omitempty"`
ReasoningEffort *string `json:"reasoning_effort,omitempty" yaml:"reasoning_effort,omitempty"`
// ReasoningContentMode controls how reasoning_content from history is handled.
// "keep_all" (keep everything), "discard_previous" (default, keep current turn only),
// "discard_all" (strip all reasoning_content).
ReasoningContentMode string `json:"reasoning_content_mode,omitempty" yaml:"reasoning_content_mode,omitempty"`
// Meditation configures the periodic meditation/heartbeat mechanism.
// Only effective when the agent is started via StartLoop.
Meditation MeditationConfig `json:"meditation,omitempty" yaml:"meditation,omitempty"`
// WorkspaceRoot is the unified on-disk scratch root for this agent
// (default: .tagent-workspace). Oversized tool outputs go to <root>/tool-output;
// the tmux command working directory is <root>/exec. A periodic cleaner bounds
// the accumulated files.
WorkspaceRoot string `json:"workspace_root,omitempty" yaml:"workspace_root,omitempty"`
// Description for agent.Agent interface (used when this agent is a sub-agent)
Description string `json:"description,omitempty" yaml:"description,omitempty"`
}
AgentConfig describes a single agent's configuration. Each agent only cares about itself and who it communicates with.
type CompressConfig ¶
type CompressConfig struct {
// CompactKeysListed caps the keys listed in the rolling compaction
// summary (default 32); older events stay retrievable via recall.
CompactKeysListed int `json:"compact_keys_listed,omitempty" yaml:"compact_keys_listed,omitempty"`
// RecentFullCount is how many most-recent refs resolve with full content
// from MemoryStore. Unset (0) derives keep_recent_tasks × 4 so the most
// recent complete turns resolve full as a whole; explicit values win.
RecentFullCount int `json:"recent_full_count,omitempty" yaml:"recent_full_count,omitempty"`
// CardMaxChars caps the index-card section of the rolling compaction
// summary (default 6000); beyond it old card lines are LLM-condensed
// (with summary_model) or sink into an "earlier n items" counter.
CardMaxChars int `json:"card_max_chars,omitempty" yaml:"card_max_chars,omitempty"`
// SummaryMaxTokens is the floor for the output-token budget reserved on each
// summary LLM call (0 = package default 8192). Reasoning models spend part
// of max_tokens on their thinking chain; too small a budget returns empty
// Content and degrades compression. The per-call budget scales up with the
// summary size but never below this floor.
SummaryMaxTokens int `json:"summary_max_tokens,omitempty" yaml:"summary_max_tokens,omitempty"`
// SummaryModel is the model name for LLM summary compression.
// Falls back to the agent's main model if empty.
SummaryModel string `json:"summary_model,omitempty" yaml:"summary_model,omitempty"`
// SummaryProvider is the provider name for the summary model.
// Falls back to the agent's provider if empty.
SummaryProvider string `json:"summary_provider,omitempty" yaml:"summary_provider,omitempty"`
}
CompressConfig configures SmartCompressor parameters.
type Config ¶
type Config struct {
// Entry specifies which agent in the Agents map is the top-level agent.
// Defaults to "tagent" if empty.
Entry string `json:"entry" yaml:"entry"`
// Agents maps agent name → AgentConfig. Each agent is independently configured.
Agents map[string]AgentConfig `json:"agents" yaml:"agents"`
// PromptDir is the global base directory for prompt file resolution.
// Individual agents can override this via their own PromptDir field.
PromptDir string `json:"prompt_dir" yaml:"prompt_dir"`
// Model is the global default model name (resolved at runtime).
// Individual agents can override this via their own Model field.
Model string `json:"model" yaml:"model"`
// Provider is the global default model provider name (e.g., "openai", "anthropic").
// Defaults to "openai" if empty. Agents can override via AgentConfig.Provider.
Provider string `json:"provider,omitempty" yaml:"provider,omitempty"`
// Providers maps provider name → connection info (endpoint, api_key_env).
// Each agent references a provider by name to resolve its model instance.
// Example:
// providers:
// openai:
// api_endpoint: "https://open.bigmodel.cn/api/paas/v4"
// api_key_env: "ZAI_API_KEY"
// anthropic:
// api_endpoint: "https://api.anthropic.com"
// api_key_env: "ANTHROPIC_API_KEY"
Providers map[string]ProviderConfig `json:"providers,omitempty" yaml:"providers,omitempty"`
// APIEndpoint is the LLM API base URL (e.g., "https://open.bigmodel.cn/api/paas/v4").
APIEndpoint string `json:"api_endpoint,omitempty" yaml:"api_endpoint,omitempty"`
// APIKeyEnv is the environment variable name holding the API key.
// Defaults to "ZAI_API_KEY" if empty.
APIKeyEnv string `json:"api_key_env,omitempty" yaml:"api_key_env,omitempty"`
// LogLevel controls framework (trpc-agent-go/log) verbosity.
// One of: "debug", "info", "warn", "error".
// Can be overridden by the LOG_LEVEL environment variable.
LogLevel string `json:"log_level,omitempty" yaml:"log_level,omitempty"`
// RequestTimeoutSeconds is the per-request timeout in seconds (0 = default 3600).
RequestTimeoutSeconds int `json:"request_timeout_seconds,omitempty" yaml:"request_timeout_seconds,omitempty"`
// App holds application-specific configuration (e.g., wechat bot settings).
// Each application deserializes this into its own typed struct.
// This keeps Config generic — no app-specific fields pollute the shared structure.
App map[string]any `json:"app,omitempty" yaml:"app,omitempty"`
// TrajectoryDump enables recording every LLM call to JSONL files on disk.
// Default: false. When true, a TrajectoryRecorder wraps the model.
TrajectoryDump bool `json:"trajectory_dump,omitempty" yaml:"trajectory_dump,omitempty"`
// TrajectoryDir is the directory for trajectory JSONL files.
// Default: "data/trajectories". Each session gets its own file: {dir}/{session_id}.jsonl
TrajectoryDir string `json:"trajectory_dir,omitempty" yaml:"trajectory_dir,omitempty"`
}
Config is the top-level tagent configuration. Declarative and serializable — loadable from YAML or JSON. Runtime-only dependencies (model instances, memory stores, etc.) are injected via Option functions.
The configuration follows an agent-centric design: each agent describes its own settings (model, memory, tools) and its communication intent (which agents it calls). The top-level Config holds a map of agent configs, keyed by agent name.
Example YAML:
agents:
tagent:
model: glm-4-flash
prompt_dir: resources/prompts
system_prompt:
files: [AGENTS.md, SOUL.md, USER.md, TOOLS.md]
memory:
type: file
path: /data/tagent/events
tools:
- agent: knowledge
description_file: knowledge_tool_desc.md
event_params: [event_key]
- agent: recall
description_file: recall_tool_desc.md
event_params: [event_key]
- kind: tool
id: action
description_file: action_tool_desc.md
knowledge:
model: glm-4-flash
prompt:
files: [knowledge_agent.md]
memory:
type: memory
max_tool_iterations: 5
max_tokens: 4096
recall:
model: glm-4-flash
prompt:
files: [recall_agent.md]
memory:
type: memory
max_tool_iterations: 5
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults and the three core agents.
func LoadConfig ¶
LoadConfig loads configuration from a YAML or JSON file. Format is auto-detected from the file extension (.yaml/.yml → YAML, .json → JSON).
func (*Config) APIKey ¶
APIKey returns the API key from the environment variable specified by APIKeyEnv.
func (*Config) ApplyDefaults ¶
func (c *Config) ApplyDefaults()
ApplyDefaults fills in zero/empty values with defaults.
func (*Config) ResolveAgentProvider ¶
ResolveAgentProvider returns the resolved API endpoint and API key environment variable name for the given agent. It honors the agent's provider override (AgentConfig.Provider) and falls back to the global provider settings. Pass an empty agentName to resolve the global provider.
type ExtraParam ¶
type ExtraParam = agent.ExtraParam
ExtraParam re-exports agent.ExtraParam for YAML/JSON config declaration (ToolRef.extra_params).
type LifecycleConfig ¶
type LifecycleConfig struct {
// GlobalTTLDays is the default time-to-live in days (default: 7).
// Negative = disable TTL entirely (no event is ever tombstoned by age).
GlobalTTLDays *int `json:"global_ttl_days,omitempty" yaml:"global_ttl_days,omitempty"`
// TypeTTL overrides the global TTL per event type (days).
// Negative value = exempt (curated artifacts never expire).
TypeTTL map[string]int `json:"type_ttl,omitempty" yaml:"type_ttl,omitempty"`
// CheckInterval is how often the lifecycle scanner runs (e.g., "1h"). Default: "1h".
CheckInterval string `json:"check_interval,omitempty" yaml:"check_interval,omitempty"`
// MaxEventsPerPartition caps events per partition (0 = unlimited, default).
MaxEventsPerPartition *int `json:"max_events_per_partition,omitempty" yaml:"max_events_per_partition,omitempty"`
}
LifecycleConfig declares the forgetting policy over YAML/JSON. Unset fields fall back to memory.DefaultLifecycleConfig values.
type MeditationConfig ¶
type MeditationConfig struct {
// Enabled activates the meditation ticker.
Enabled bool `json:"enabled" yaml:"enabled"`
// Interval is the check interval (e.g., "30m"). Default: "30m".
Interval string `json:"interval,omitempty" yaml:"interval,omitempty"`
// MinGap is the minimum idle duration before meditation fires (e.g., "2h"). Default: "2h".
MinGap string `json:"min_gap,omitempty" yaml:"min_gap,omitempty"`
// PromptFile is the meditation prompt file (relative to prompt_dir). Default: "meditation.md".
PromptFile string `json:"prompt_file,omitempty" yaml:"prompt_file,omitempty"`
}
MeditationConfig configures the periodic meditation/heartbeat mechanism. Uses string durations (e.g., "30m", "2h") for YAML/JSON serialization. tagent.go converts these to time.Duration for agent.MeditationConfig.
type MemoryConfig ¶
type MemoryConfig struct {
// Type selects the memory store implementation:
// "memory" — in-memory store (default, lost on process exit)
// "file" — file-backed persistent store (requires rustviking CLI)
// "localfile" — file-backed persistent store (JSON file KV, no external deps)
Type string `json:"type" yaml:"type"`
// Path is the storage location identifier:
// - For "file"/"localfile" type: filesystem directory path
// - For "memory" type: logical store identifier — agents with the same
// type: memory and same path share a single InMemoryStore instance
// Empty value means an isolated store (no sharing).
Path string `json:"path,omitempty" yaml:"path,omitempty"`
// ReadNamespaces lists agent names whose storage partitions this agent
// is allowed to read. Each name is converted to a PartitionID at build time.
// For example, recall can read tagent's events by declaring:
// read_namespaces: [tagent]
// This enables cross-agent memory access across partitions.
ReadNamespaces []string `json:"read_namespaces,omitempty" yaml:"read_namespaces,omitempty"`
// RustVikingBinary sets the rustviking CLI binary path for "file" type stores.
// Empty value uses "rustviking" (looked up via PATH).
RustVikingBinary string `json:"rustviking_binary,omitempty" yaml:"rustviking_binary,omitempty"`
// Lifecycle configures TTL / capacity-based forgetting for this store.
// Nil keeps the built-in defaults (global TTL 7d, per-type table, 1h checks).
Lifecycle *LifecycleConfig `json:"lifecycle,omitempty" yaml:"lifecycle,omitempty"`
}
MemoryConfig configures an agent's memory store. Each agent has its own isolated storage instance.
type Option ¶
type Option func(*runtimeConfig)
Option injects runtime-only dependencies that cannot be serialized.
func WithMCPToolSets ¶
WithMCPToolSets sets the MCP tool sources for knowledge agent.
func WithModel ¶
WithModel sets the resolved model instance (required). This is the default model; individual agents can override via AgentConfig.Model.
func WithModelOverrides ¶
WithModelOverrides injects pre-resolved model instances for specific agents. This supports scenarios like SwappableModel for entry agent (AReaL proxy). The map key is the agent name, the value is the model instance to use.
func WithSkillRepo ¶
func WithSkillRepo(sr tool.SkillRepository) Option
WithSkillRepo sets the skill repository for knowledge agent.
func WithSummaryModel ¶
WithSummaryModel sets the model for Stage 2 LLM summary compression.
type PromptConfig ¶
type PromptConfig = prompt.CompositeConfig
PromptConfig is an alias for prompt.CompositeConfig, providing bootstrap-style prompt loading aligned with nanobot's pattern (AGENTS.md, SOUL.md, USER.md, TOOLS.md).
Prompt composition order: inline → files (in order) → directory scan.
type ProviderConfig ¶
type ProviderConfig struct {
// Provider is the protocol implementation to use (e.g., "openai", "anthropic", "gemini").
// Most domestic models (GLM, DeepSeek, Moonshot, etc.) use OpenAI-compatible protocol,
// so this field should be "openai" with different api_endpoint to distinguish providers.
// Defaults to the provider registry key name if not specified.
// e.g., "openai" for OpenAI-compatible APIs (OpenAI/ZhiPu/DeepSeek/Moonshot/Baichuan/Qwen),
// "anthropic" for Anthropic Claude,
// "gemini" for Google Gemini.
Provider string `json:"provider,omitempty" yaml:"provider,omitempty"`
// APIEndpoint is the base URL for the provider's API.
// e.g., "https://open.bigmodel.cn/api/paas/v4" for ZhiPu,
// "https://api.anthropic.com" for Anthropic.
APIEndpoint string `json:"api_endpoint" yaml:"api_endpoint"`
// APIKeyEnv is the environment variable name holding the API key for this provider.
// e.g., "ZAI_API_KEY", "ANTHROPIC_API_KEY".
APIKeyEnv string `json:"api_key_env,omitempty" yaml:"api_key_env,omitempty"`
}
ProviderConfig holds connection info for a model provider. Used in Config.Providers to declare provider endpoints and credentials.
type RemoteConfig ¶
type RemoteConfig struct {
// URL is the A2A agent card endpoint (e.g., "http://knowledge-service:8088").
// The remote agent must expose an A2A server with agent card at /.well-known/agent.json.
URL string `json:"url" yaml:"url"`
}
RemoteConfig declares A2A connection info for a remote sub-agent. tagent YAML only declares the URL; trpc communication options (TransferStateKey, streaming, etc.) are derived internally by tagent.go.
type ToolRef ¶
type ToolRef struct {
// Kind distinguishes agent tools from plain tools. Defaults to "agent".
Kind ToolKind `json:"kind" yaml:"kind"`
// AgentID references another agent in the Agents map (kind=agent).
// The referenced agent becomes a CallableTool for this agent.
AgentID string `json:"agent,omitempty" yaml:"agent,omitempty"`
// ID is the tool identifier for plain tools (kind=tool).
ID string `json:"id,omitempty" yaml:"id,omitempty"`
// Tool description: inline or from file (relative to prompt_dir)
Description string `json:"description,omitempty" yaml:"description,omitempty"`
DescriptionFile string `json:"description_file,omitempty" yaml:"description_file,omitempty"`
// EventParams declares which event-derived parameters this tool requires.
// When the parent agent's LLM outputs a tool call, it includes these parameter values
// (e.g., "event_key"). The tool wrapper then resolves them: for event_key, it fetches
// the complete event data from the parent agent's MemStore and passes it as external
// context to the tool agent. This prevents the LLM from breaking context isolation —
// the LLM only outputs a numeric key, but the actual event content is resolved server-side.
EventParams []string `json:"event_params,omitempty" yaml:"event_params,omitempty"`
// ExtraParams declares additional routing-level parameters for agent-kind
// tools (plan-interaction-contract D2). Each declared parameter is added to
// the tool's InputSchema and, when present in a call, packed together with
// request into a JSON message body passed to the sub-agent (e.g. plan's
// action/name). Tools without extra_params keep the plain-text request
// message unchanged.
ExtraParams []ExtraParam `json:"extra_params,omitempty" yaml:"extra_params,omitempty"`
// Async controls whether an agent-kind tool may run through the async task
// layer (sync-wait window → inline result or background ack + task_settled).
// nil/true = async allowed (default); false = always run synchronously —
// an operator knob to reduce cognitive load on weaker models that struggle
// with ack/notification semantics.
Async *bool `json:"async,omitempty" yaml:"async,omitempty"`
// Properties holds tool-specific configuration that each tool factory
// deserializes into its own typed struct. This keeps ToolRef generic
// — no tool-specific fields pollute the shared structure.
//
// Example (action tool):
//
// properties:
// workspace: /tmp/tagent-workspace
// run_as_user: tagent-runner
// run_as_group: tagent-runner
Properties map[string]any `json:"properties,omitempty" yaml:"properties,omitempty"`
// Remote declares that this agent tool is a remote A2A agent.
// When set, tagent creates an a2aagent.A2AAgent instead of a local TagentAgent.
// The URL is the agent card endpoint (e.g., "http://knowledge-service:8088").
// Context is passed via RuntimeState → A2A metadata (auto-mapped by trpc framework).
//
// This field embodies the configuration layer separation:
// - tagent YAML: agent definition (model, prompt, etc.) — here
// - ToolRef.Remote.URL: connection info ("where is this agent?") — here
// - trpc Go options: communication details (A2A protocol, TransferStateKey) — internal
Remote *RemoteConfig `json:"remote,omitempty" yaml:"remote,omitempty"`
// Extension: custom factory path (for non-builtin tools/agents)
Factory string `json:"factory,omitempty" yaml:"factory,omitempty"`
}
ToolRef declares a tool that an agent uses. For agent-kind tools, the AgentID field references another AgentConfig in the Agents map. For tool-kind tools, the ID field identifies the plain tool factory.
type ToolRegistry ¶
type ToolRegistry struct{}
ToolRegistry is a facade over the agent package's global tool registration maps. It provides a unified entry point for tool registration, lookup, and validation.
The actual factory maps live in agent/tool_agent.go as package-level variables. ToolRegistry delegates to those maps so callers can register tools via either the ToolRegistry API or agent.RegisterPlainTool / agent.RegisterToolAgent directly.
func GetRegistry ¶
func GetRegistry() *ToolRegistry
GetRegistry returns the global ToolRegistry singleton.
func (*ToolRegistry) GetPlainToolFactory ¶
func (r *ToolRegistry) GetPlainToolFactory(id string) (agent.PlainToolFactory, bool)
GetPlainToolFactory returns the factory for the given plain tool ID.
func (*ToolRegistry) GetToolAgentFactory ¶
func (r *ToolRegistry) GetToolAgentFactory(id string) (agent.ToolAgentFactory, bool)
GetToolAgentFactory returns the factory for the given tool agent ID.
func (*ToolRegistry) RegisterPlainTool ¶
func (r *ToolRegistry) RegisterPlainTool(id string, factory agent.PlainToolFactory)
RegisterPlainTool registers a plain tool factory. Delegates to agent.RegisterPlainTool.
func (*ToolRegistry) RegisterToolAgent ¶
func (r *ToolRegistry) RegisterToolAgent(id string, factory agent.ToolAgentFactory)
RegisterToolAgent registers a tool agent factory. Delegates to agent.RegisterToolAgent.
func (*ToolRegistry) ValidateToolAccess ¶
func (r *ToolRegistry) ValidateToolAccess(cfg *Config) error
ValidateToolAccess checks that all config-referenced plain tools (kind: tool) are registered in the ToolRegistry. Returns an error on the first unregistered tool.
Agent-kind tools (kind: agent) are not checked here — they reference other agents in the Config.Agents map, which is validated separately in Config.Validate().
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent provides tagent's core agent mechanism coordination.
|
Package agent provides tagent's core agent mechanism coordination. |
|
Package-level event metadata contract (unified-event-projection D4).
|
Package-level event metadata contract (unified-event-projection D4). |
|
Package prototype contains the original 126-line tagent skeleton.
|
Package prototype contains the original 126-line tagent skeleton. |
|
Package rl provides reinforcement learning utilities for tagent agents.
|
Package rl provides reinforcement learning utilities for tagent agents. |
|
file
Package file wraps trpc-agent-go's built-in file operation tools for tagent.
|
Package file wraps trpc-agent-go's built-in file operation tools for tagent. |
|
knowledge
Package knowledge provides tools for the Knowledge Agent (skill search + web search + MCP discovery).
|
Package knowledge provides tools for the Knowledge Agent (skill search + web search + MCP discovery). |
|
plan
Package plan implements the PlanAgent — a TagentAgent wrapper with custom Run that bypasses the LLM for progress queries.
|
Package plan implements the PlanAgent — a TagentAgent wrapper with custom Run that bypasses the LLM for progress queries. |
|
recall
memory_recall: the recall PROTOCOL implementation (unified-memory-curation D6), now internal — the model-facing entry is the unified `recall` tool (recall.go, stable-context-compaction D7) which routes items/query through recallByItems/recallByQuery below.
|
memory_recall: the recall PROTOCOL implementation (unified-memory-curation D6), now internal — the model-facing entry is the unified `recall` tool (recall.go, stable-context-compaction D7) which routes items/query through recallByItems/recallByQuery below. |
|
spec
Package spec provides an LLM-facing tool for managing specification-driven work plans (create / status / validate / archive / …) without handing the agent a general shell.
|
Package spec provides an LLM-facing tool for managing specification-driven work plans (create / status / validate / archive / …) without handing the agent a general shell. |
|
task
Package task provides LLM-facing tools for managing async background tasks tracked by the agent's TaskManager: listing, cancelling, and relaunching.
|
Package task provides LLM-facing tools for managing async background tasks tracked by the agent's TaskManager: listing, cancelling, and relaunching. |
|
Package workspace centralizes tagent's on-disk scratch space (oversized tool outputs) under one root, and provides a periodic cleaner that bounds the accumulated files (by age and count).
|
Package workspace centralizes tagent's on-disk scratch space (oversized tool outputs) under one root, and provides a periodic cleaner that bounds the accumulated files (by age and count). |