Repository navigation
Description
Revised per ADR-036 and senior-architect review. The original "universal
invoke_toolwith flat parameters" is DROPPED — head-to-head testing showed it causes the exact malformed-structured-output failures it was meant to avoid. Tools remain typed at the inference boundary. The tools-as-nodes storage/bridge concept is kept and extended with typed-tool generation + an external-tool trust boundary.
Overview
Promote each tool to a graph node (node_type='tool') that bridges the graph/LLM layer to a deterministic Rust handler. Tool nodes are the storage, discovery, and whitelist layer; the model is presented typed, named, scoped tool definitions generated FROM those nodes — never a single universal invoker.
Stack: user intent → skill (instructions) → tool node (bridge) → deterministic handler. Everything above the tool node is graph/LLM-mediated; everything below is deterministic.
Why NOT a universal invoke_tool (evidence)
Same model, same pushed skill, same request:
- Typed nested
create_schema→ ✅ flawless structured output (correct enumcoreValues,title_template, valid types). - Universal
invoke_tool(tool_id, flat_args)→ ❌ corrupted, stringified, broken-quoting JSON.
A model cannot reliably emit nested structure as an opaque flat blob (structural result). Typed tools let the engine's templating + schema constrain the output.
Proposed Solution
1. Tool nodes (node_type='tool')
ToolNodeBehavior+ seed one node per existing tool.- Properties: stable
handlerkey (→ deterministic fn registry), the tool's parameter schema (typed, may be nested), description (embeddable for discovery), and asourceprovenance marker (internal-generated vs external).
2. Stable-key binding
- Registry maps
handler key → deterministic fn(generalizes today'sexecute(name, args)match). The node points at logic; it never contains logic.
3. Typed tools generated from nodes at the inference boundary
- At assembly time, generate typed, named
ToolDefinitions from the matched skill's whitelisted tool nodes. The model sees scoped typed tools — NOTinvoke_tool.
4. External-tool trust boundary (ADR-035 coupling)
Because this surface is also the external-agent surface, the registry is an attack surface (tool-squatting / prompt injection via a tool's embedded description):
- Registration gated; external tools require explicit user enablement before entering the retrieval set.
- Provenance marker (
source) visible to the retrieval filter, the Stage-2 judge, and the UI. - Generated-schema validation before inference: bounded nesting depth, no unbounded
additionalProperties, size cap. - One trust model for internal-generated and external-registered tools alike.
5. Uniform addressing
- Tool nodes have
nodespace://URIs; a skill references a tool like it references another skill. A skill'stool_whitelistholds tool node IDs.
Acceptance Criteria
- Each existing tool seeded as a
node_type='tool'node withhandlerkey, typed parameter schema, description, andsourcemarker. -
handler key → deterministic fnregistry resolves tool nodes to handlers; no logic in the node. - Typed, named, scoped tool definitions are generated FROM tool nodes at assembly time; the model is NOT presented a universal
invoke_tool. -
tool_whitelistholds tool node IDs; tool nodes havenodespace://URIs. - External-tool registration is gated + requires explicit enablement; provenance marker present; generated schemas validated (depth/size/additionalProperties bounds).
-
create_schema(nested) continues to work as a typed tool (proven reliable when delivered with skill instructions). - Code passes
bun run quality:fix; tests pass.
Technical Specifications
Reference Files
packages/agent/src/local_agent/tools.rs— typedToolDefinitionsurface (:193-741),executedispatch (:1620),def_create_schema(:445).packages/core/src/behaviors/mod.rs— addToolNodeBehavior.packages/agent/src/skill_pipeline.rs— seed tool nodes;tool_whitelist→ node IDs.packages/agent/src/local_agent/agent_loop.rs—available_tools()→ typed-from-nodes generation.
Dependencies
- llama.cpp upgrade issue (typed-tool reliability validated on the upgraded engine)
Related Issues
- ADR-036 (the decision — typed tools, no universal invoker, trust boundary)
- ADR-035 (external-agent surface — why the trust boundary lives here)
- Skill-mediated tool routing: LLM-judged two-stage retrieval pipeline with clarification fallback #1352 (routing — the matched skill scopes which typed tools are generated)
Non-Goals
- Universal
invoke_tool/ flat-param collapse (rejected). - A user-facing tool authoring/marketplace UI.
Activity
[-]Tools as nodes: seed tools as graph nodes that bridge to deterministic handlers, invoked via a universal invoke_tool with flat parameters[/-][+]Tools as nodes: deterministic-handler bridge with TYPED tools generated from nodes (no universal invoker), plus external-tool trust boundary[/+]malibio commentedon Jun 6, 2026
Frontend baseline: 134 files, 3844 tests passed
Tools as nodes: deterministic-handler bridge with TYPED tools generat…
Tools as nodes: deterministic-handler bridge with TYPED tools generat…