Jido.AI.Directive.ToolExec (Jido AI v2.2.0)

Copy Markdown View Source

Directive to execute a Jido.Action as a tool.

The runtime will execute this asynchronously and send the result back as a ai.tool.result signal.

Execution Modes

  1. Direct module execution (preferred): When action_module is provided, the module is executed directly via Turn.execute_module/4, bypassing name-based lookup. This is used by strategies that maintain their own tool lists.

  2. Name lookup: When action_module is nil, runtime resolves the tool name against the current strategy/plugin tool map and executes via Jido.AI.Turn.

Argument Normalization

LLM tool calls return arguments with string keys (from JSON). The execution normalizes arguments using the tool's schema before execution:

  • Converts string keys to atom keys
  • Parses string numbers to integers/floats based on schema type

This ensures consistent argument semantics whether tools are called via DirectiveExec or any other path.

Summary

Functions

Create a new ToolExec directive.

Types

t()

@type t() :: %Jido.AI.Directive.ToolExec{
  action_module: nil | atom(),
  arguments: map(),
  context: map(),
  id: binary(),
  iteration: nil | integer(),
  max_retries: integer(),
  metadata: map(),
  request_id: nil | binary(),
  retry_backoff_ms: integer(),
  timeout_ms: nil | integer(),
  tool_name: binary()
}

Functions

new!(attrs)

Create a new ToolExec directive.