Codex.Approvals (Codex SDK v0.3.0)

View Source

Approval helpers invoked by the auto-run pipeline when actions require consent.

Supports both synchronous and asynchronous approval workflows via pluggable hooks.

Summary

Functions

Reviews a tool invocation given the configured policy or hook.

Types

async_result()

@type async_result() ::
  {:async, reference()} | {:async, reference(), metadata :: map()}

decision()

@type decision() :: :allow | {:deny, String.t()}

review_result()

@type review_result() :: decision() | async_result()

Functions

review_tool(policy_or_hook, event, context, opts \\ [])

@spec review_tool(term(), map(), map(), keyword()) :: review_result()

Reviews a tool invocation given the configured policy or hook.

Parameters

  • policy_or_hook - StaticPolicy struct, hook module, or nil
  • event - Tool call event (must contain :tool_name and :call_id)
  • context - Approval context
  • opts - Optional keyword list with :timeout (default: 30_000ms)

Returns

  • :allow - approve the operation
  • {:deny, reason} - deny with reason
  • {:async, ref} or {:async, ref, metadata} - async approval pending

Telemetry

Emits the following events:

  • [:codex, :approval, :requested] - when approval is requested
  • [:codex, :approval, :approved] - when synchronously approved
  • [:codex, :approval, :denied] - when denied
  • [:codex, :approval, :timeout] - when async approval times out