Pixir.Tools.Executor (pixir v0.1.0)

Copy Markdown View Source

Central tool execution (CONTEXT.md): Pixir — not the model — runs Tools. The Executor resolves the tool, validates args against its schema, then dispatches to execute/2 (or dry_run/2 when context.dry_run).

run/2 is the Turn-loop entry point: it records the canonical tool_call Event before running and the tool_result Event after (both via Pixir.Session, so they get a seq, hit the Log, and publish). execute_call/2 is the side-effect-free core (no Events) used directly in unit tests.

Summary

Functions

Resolve, validate, and run (or dry-run) a tool call without emitting Events.

Run a tool call within a Session: record tool_call, apply the permission policy (ADR 0006), execute (or refuse), record tool_result. Returns the raw {:ok, result} | {:error, structured} from the tool.

Types

call()

@type call() :: %{call_id: String.t(), name: String.t(), args: map()}

Functions

execute_call(map, context)

@spec execute_call(%{name: String.t(), args: map()}, Pixir.Tool.context()) ::
  Pixir.Tool.result()

Resolve, validate, and run (or dry-run) a tool call without emitting Events.

run(map, context)

Run a tool call within a Session: record tool_call, apply the permission policy (ADR 0006), execute (or refuse), record tool_result. Returns the raw {:ok, result} | {:error, structured} from the tool.

The permission policy is read from context.permission (%{mode, asker}); it defaults to :auto (allow everything) so the common path has zero overhead.