Skip to main content

Module tool_executor

Module tool_executor 

Source
Expand description

Native tool executors — Calculator and DateTimeTool.

Tools are pure functions that execute locally (no LLM call). When a use_tool step references a known tool, the runner intercepts it and calls the executor directly.

Supported tools:

  • Calculator: safe arithmetic expression evaluator
  • DateTimeTool: current date/time/timestamp queries

Structs§

ToolResult
Result of a tool execution.

Functions§

calculator_execute
Safe arithmetic expression evaluator.
datetime_execute
Current date/time queries using system time (UTC).
dispatch
Dispatch a tool call by name. Returns None if the tool is not a native executor AND is not a declared-but-unimplemented stdlib tool (those legacy names still fall through to the LLM — see dispatch_or_reject for the stricter contract the runtime uses at real call sites).
dispatch_or_reject
v2.53.0 section 8 — the honest dispatch: a tool name DECLARED in stdlib::TOOLS but with no native executor and no LLM provider is a typed refusal, not a silent hand-off to the model. This closes the pre-existing defect where calling e.g. PDFExtractor (declared, unimplemented) returned the model inventing the PDF’s contents, shaped exactly like a real extraction. Returns Err for such names; Ok(Some) for a real native result; Ok(None) for a name with a legitimate non-native (LLM/provider) path.