Skip to main content

Module tool_node

Module tool_node 

Source
Expand description

The generic tool node and NativeTools, a ToolRuntime built from Rust closures.

The tool node calls one tool of a provider registered in the ToolRegistry service:

- id: weather
  type: tool
  provider_id: builtin          # or e.g. "mcp:github"
  tool_name: get_weather
  tool_parameters:
    city:  { type: variable, value: [start, city] }
    units: { type: constant, value: metric }
    note:  { type: mixed,    value: "asked by {{#sys.user_id#}}" }

A simpler arguments map is also accepted: string values are templates (a lone {{#a.b#}} placeholder keeps its typed value), other values are constants.

tool_context sends per-run values to the tool beside the arguments, for providers that accept them (the workspace tools take the user’s directory this way with --workspace-per-user):

  tool_context:
    scope: "{{#sys.user_id#}}"

A tool with a price (image/generate with a per_image price) gets what the run’s cost budget leaves and reports what the call cost: the node charges it to the budget and reports it as usage.cost_micros.

Outputs: text (string), json (structured result, or null; when the text looks like JSON but does not parse, metadata json_error says why), files (array, currently always empty), is_error (bool) and error (the tool’s error text, or null). A tool-reported error fails the node unless ignore_tool_errors is set, in which case is_error / error let a downstream branch react. variable arguments that do not resolve are sent as null and listed in metadata missing_arguments.

Structs§

NativeTools
A ToolRuntime whose tools are Rust closures.
ToolNode
Calls one tool from the ToolRegistry service.

Constants§

KIND
Node kind handled by ToolNode.

Functions§

descriptor
Catalog descriptor of the tool node.
register
Register the tool node kind.