Skip to content

Tools as nodes: deterministic-handler bridge with TYPED tools generated from nodes (no universal invoker), plus external-tool trust boundary #1353

Closed

Description

@malibio

Revised per ADR-036 and senior-architect review. The original "universal invoke_tool with 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 enum coreValues, 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 handler key (→ deterministic fn registry), the tool's parameter schema (typed, may be nested), description (embeddable for discovery), and a source provenance marker (internal-generated vs external).

2. Stable-key binding

  • Registry maps handler key → deterministic fn (generalizes today's execute(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 — NOT invoke_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's tool_whitelist holds tool node IDs.

Acceptance Criteria

  • Each existing tool seeded as a node_type='tool' node with handler key, typed parameter schema, description, and source marker.
  • handler key → deterministic fn registry 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_whitelist holds tool node IDs; tool nodes have nodespace:// 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 — typed ToolDefinition surface (:193-741), execute dispatch (:1620), def_create_schema (:445).
  • packages/core/src/behaviors/mod.rs — add ToolNodeBehavior.
  • 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

Non-Goals

  • Universal invoke_tool / flat-param collapse (rejected).
  • A user-facing tool authoring/marketplace UI.

Activity

  1. changed the title [-]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[/+] on Jun 6, 2026
  2. malibio commented on Jun 6, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 134 files, 3844 tests passed

  3. self-assigned this
    on Jun 6, 2026
  4. added a commit that references this issue on Jun 6, 2026
    57f92ce
  5. added a commit that references this issue on Jun 22, 2026
    3b60a1d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions