tools / registry.py

Single source of truth for every LLM-facing tool. Builds the active definition list per turn, dispatches calls, injects context.

Built-in tools

Tool nameModulePurpose
delegate_to_swarmswarmFire-and-forget background task dispatch with optional blocking await.
system_utilitysystemDiagnostics / health / weather / location.
file_systemfile_systemUnified read / write / search / list / find / download / move / delete.
knowledge_basememory toolsMemory ingestion: insert_fact, ingest_document, forget, list_docs, reset_all.
recallmemory toolsVector semantic search.
executeexecuteCode execution: Python / Node / Bash; stateful Jupyter.
learn_skillmemory toolsPersistent lesson storage.
web_searchsearchAnonymous DDG search via Tor.
deep_researchsearchMulti-source synthesis (falls back to web_search).
fact_checksearchClaim verification using deep_research.
update_profilememory toolsPersistent user facts.
manage_projectsprojectsProject lifecycle + tasks.
manage_taskstasksCron / interval background jobs.
dream_modememory toolsActive memory consolidation trigger.
self_playmemory toolsOne synthetic self-training cycle (600 s wall-clock cap).
self_play_loopmemory toolsContinuous background self-play loop; stops on any user message or stop_self_play. Optional max_cycles and model override.
stop_self_playmemory toolsStop the running self-play loop after its current cycle.
list_lessonsmemory toolsSurface the LESSON playbook (mistakes-and-fixes the agent has internalized). scope ∈ {today, week, all, self_play_only}. Read-only; exempt from the meta-task compliance nudge. NOT for "show me your skills" — that is a TOOL list and routes to manage_skills.
replancore/agentStrategy reset signal.
abort_attemptcore/agentEscape hatch for unsolvable tasks.
scratchpadmemory toolsShort-term KV: set / get / list / clear.
postgres_admindatabaseSQL exec, schema dump, EXPLAIN ANALYZE, activity.
create_skillacquired_skillsTDD-validated skill acquisition.
manage_skillsacquired_skillsList / delete the agent's acquired SKILLS (custom Python tools created via create_skill). This is the routing target for "show me your skills", "list your skills", "what skills do you have". Distinct from list_lessons: a SKILL is a tool, a LESSON is a mistake-and-fix.
vision_analysisvisionImage / PDF analysis (auto-registered when vision-capable LLM available).
image_generationimage_genSDXL gen (auto-registered when image_gen_clients configured).

Plus dynamic tools added at runtime: every active acquired skill and every registered composed skill appears as its own LLM-facing tool definition.

Active list construction

get_active_tool_definitions(context, query) assembles the per-turn tool list:

  1. Start with the static TOOL_DEFINITIONS array.
  2. Append vision_analysis when the LLM client supports vision (line 234).
  3. Append image_generation when context.llm_client.image_gen_clients exists (line 262).
  4. If a query is provided, RAG-retrieve relevant acquired skills via memory_system.collection.query(query_texts=[query], where={"type": "acquired_skill"}) and inject only the matches (line 293-309).
  5. Otherwise inject every active-status acquired skill that doesn't shadow a built-in (line 312-337).
  6. register_composed_skills(active_tools, context) appends macro tools (line 345-348).
  7. _intent_filter drops tools whose required configuration is missing (e.g. postgres_admin without a DSN).

Dispatch & handler binding

get_available_tools(context) returns a dict of tool_name → async lambda. Each lambda binds the live sandbox_dir, memory_system, llm_client, scheduler, and other context state to the underlying tool function so the tool implementations stay stateless.

Acquired skills run via tool_execute(filename=f"acquired_skills/{name}.py", args=[json_kwargs]) (line 436). Success / failure telemetry is recorded by manager.log_telemetry(name, success).

Fallback & failure routing

A failure raised by any tool is classified by tool_failure.classify(). RETRYABLE failures retry with exponential backoff (max 3 attempts). FATAL trigger replan. DIAGNOSTIC inject the full error so the LLM can self-correct. UNKNOWN inject a brief notice. Per-tool fallback chains in fallback_chains.py suggest alternatives.

Diagram

LLM emits <tool_call>{name, args}</tool_call> registry: lookup async lambda → bind sandbox / memory / llm context dispatch tool (sandboxed) acquired skill → tool_execute(acquired_skills/X.py) tool_failure.classify → retry / fatal / diagnostic / unknown

Figure 7 — Tool-call dispatch path through the registry.