Jido.AI.Reasoning.ReAct.RequestTransformer behaviour (Jido AI v2.1.0)

View Source

Behavior for advanced per-turn ReAct request shaping.

A request transformer can inspect the current runtime state and tool context before each LLM turn, then return request overrides.

This is intended for patterns such as:

  • request-scoped tool gating
  • dynamic structured-output schemas
  • provider-specific llm_opts based on tool results
  • custom message projection beyond the default context rendering

The runtime always regenerates llm_opts[:tools] from the returned tools field so the exposed LLM tools and execution registry stay aligned.

Summary

Functions

Fingerprint a validated transformer for checkpoint compatibility.

Validate a request transformer module.

Types

overrides()

@type overrides() :: %{
  optional(:messages) => [map()],
  optional(:llm_opts) => keyword() | map(),
  optional(:tools) => Jido.AI.Reasoning.ReAct.ToolSelection.tools_input()
}

request()

@type request() :: %{
  messages: [map()],
  llm_opts: keyword(),
  tools: Jido.AI.Reasoning.ReAct.ToolSelection.tools_input()
}

Callbacks

transform_request(request, t, t, map)

@callback transform_request(
  request(),
  Jido.AI.Reasoning.ReAct.State.t(),
  Jido.AI.Reasoning.ReAct.Config.t(),
  map()
) :: {:ok, overrides()} | {:error, term()}

Functions

fingerprint(module)

@spec fingerprint(module() | nil) :: String.t()

Fingerprint a validated transformer for checkpoint compatibility.

validate(module)

@spec validate(module() | nil) ::
  {:ok, module() | nil}
  | {:error, :invalid_request_transformer}
  | {:error, {:request_transformer_not_loaded, module()}}
  | {:error, {:request_transformer_missing_callback, module()}}

Validate a request transformer module.