Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Tools

The agent has 15 built-in tools organized into three categories: core knowledge tools, external interaction tools, and advanced tools.

Tool Architecture

Each tool implements the Tool trait:

#![allow(unused)]
fn main() {
pub trait Tool: Send + Sync {
    fn signature(&self) -> ToolSignature;
    fn execute(&self, engine: &Engine, input: ToolInput) -> AgentResult<ToolOutput>;
    fn manifest(&self) -> ToolManifest;
}
}

Tools produce a ToolOutput with:

  • success: bool -- whether the operation succeeded
  • result: String -- human-readable summary
  • symbols_involved: Vec<SymbolId> -- entities touched (linked in working memory)

Core Knowledge Tools

kg_query

Query the knowledge graph by symbol, predicate, or direction.

ParameterRequiredDescription
symbolyesSymbol name or ID to query
predicatenoFilter by predicate
directionnooutgoing (default) or incoming

kg_mutate

Create new triples in the knowledge graph.

ParameterRequiredDescription
subjectyesSubject entity label
predicateyesRelation label
objectyesObject entity label
confidencenoConfidence score (default: 0.8)

memory_recall

Fetch episodic memories relevant to the current context.

ParameterRequiredDescription
query_symbolsyesComma-separated symbol names to match against
top_knoMaximum results (default: 5)

reason

Simplify expressions via e-graph rewriting.

ParameterRequiredDescription
expryesExpression to simplify
verbosenoShow e-graph state

Find similar symbols via VSA hypervector similarity.

ParameterRequiredDescription
symbolyesSymbol name or ID
top_knoMaximum results (default: 5)

External Interaction Tools

file_io

Read and write files, sandboxed to the workspace's scratch directory.

ParameterRequiredDescription
operationyesread or write
pathyesFile path (relative to scratch dir)
contentwrite onlyContent to write

Limits: 4 KB read truncation, 256 KB write limit.

http_fetch

Synchronous HTTP GET via ureq.

ParameterRequiredDescription
urlyesURL to fetch
timeout_secsnoRequest timeout (default: 30)

Limit: 256 KB response truncation.

shell_exec

Execute shell commands with poll-based timeout.

ParameterRequiredDescription
commandyesShell command to run
timeout_secsnoTimeout (default: 30)

Limits: 64 KB output, process killed on timeout.

user_interact

Prompt the user for input via stdout/stdin.

ParameterRequiredDescription
promptyesQuestion to display
timeout_secsnoInput timeout

Advanced Tools

infer_rules

Run forward-chaining inference via e-graph rewrite rules.

ParameterRequiredDescription
max_iterationsnoRule application iterations (default: 10)
min_confidencenoMinimum confidence threshold (default: 0.5)

gap_analysis

Discover knowledge gaps by analyzing the graph structure.

ParameterRequiredDescription
goalnoFocus analysis around a specific goal
max_gapsnoMaximum gaps to report (default: 10)

csv_ingest

Ingest structured data from CSV files.

ParameterRequiredDescription
pathyesPath to CSV file
formatnospo (subject-predicate-object) or entity (header columns as predicates)

text_ingest

Extract facts from natural language text using the grammar parser.

ParameterRequiredDescription
textyesText to parse, or file:/path to read from file
max_sentencesnoMaximum sentences to process

code_ingest

Parse Rust source code into knowledge graph entities.

ParameterRequiredDescription
pathyesPath to Rust source file or directory
recursivenoRecurse into subdirectories
run_rulesnoApply inference rules after ingestion
enrichnoRun semantic enrichment

docgen

Generate documentation from code knowledge in the graph.

ParameterRequiredDescription
targetyesSymbol or path to document
formatnomarkdown, json, or both
polishnoApply grammar polishing

Danger Metadata

Each tool carries a ToolManifest with danger metadata:

#![allow(unused)]
fn main() {
DangerLevel::Safe     // No external I/O (kg_query, reason, etc.)
DangerLevel::Caution  // Read-only external access (http_fetch, file_io read)
DangerLevel::Danger   // Write/exec capability (shell_exec, file_io write)
}

Capabilities tracked:

  • ReadKg, WriteKg -- knowledge graph operations
  • FileIo -- filesystem access
  • NetworkAccess -- HTTP requests
  • ShellExec -- command execution
  • UserInteraction -- stdin/stdout

The psyche system uses shadow_triggers from the manifest to match veto patterns against tool usage.

Tool Selection

During the Decide phase, each tool receives a utility score:

total_score = base_score - recency_penalty + novelty_bonus
            + episodic_bonus + pressure_bonus + archetype_bonus

The tool with the highest score is selected. See OODA Loop for details on the scoring factors.

Custom Tools via Skills

Skill packs can register additional tools:

  • CLI tools: JSON manifests describing shell commands.
  • WASM tools: WebAssembly components (requires wasm-tools feature).
# List all registered tools (built-in + skill-provided)
akh-medu agent tools

Listing Tools

akh-medu agent tools

This shows all registered tools with their names, descriptions, parameters, and danger levels.