Jido.AI.Reasoning.ReAct.ToolSelection (Jido AI v2.1.0)

View Source

Helpers for resolving request-scoped tool registries in ReAct.

This keeps tool selection deterministic across:

  • base strategy/runtime config
  • request-scoped tools overrides
  • request-scoped allowed_tools allowlists

Summary

Functions

Filter a tool registry by allowed tool names.

Normalize arbitrary tool input into a validated action map.

Resolve an effective tool registry from a base registry plus optional overrides.

Types

tools_input()

@type tools_input() :: nil | map() | [module()] | module()

tools_map()

@type tools_map() :: %{required(String.t()) => module()}

Functions

filter_allowed(tools, allowed_tools)

@spec filter_allowed(tools_map(), [String.t()] | nil) ::
  {:ok, tools_map()} | {:error, term()}

Filter a tool registry by allowed tool names.

normalize_input(tools)

@spec normalize_input(tools_input()) :: {:ok, tools_map()} | {:error, term()}

Normalize arbitrary tool input into a validated action map.

resolve(base_tools, override_tools \\ nil, allowed_tools \\ nil)

@spec resolve(tools_map(), tools_input(), [String.t()] | nil) ::
  {:ok, tools_map()} | {:error, term()}

Resolve an effective tool registry from a base registry plus optional overrides.

override_tools replaces the base registry for the current request/run when present. allowed_tools filters the selected registry by tool name.