ExAgent.ExecutionScope (ExAgent v2.2.2)

View Source

Ephemeral admission and accounting for one execution tree.

The handle is runtime-only: do not serialize it. Each node retains its own restrictions and every admission checks all ancestors atomically. Model slots are fail-fast, never held while tools or delegates run. Usage is reconciled by operation identity; this is not exactly-once execution of external effects. request_count counts admitted Model attempts (not necessarily HTTP requests for a custom Model); tool_calls counts exact batch reservations, not dispatches or successful effects. Terminal finalization is independent of metric coverage.

Deadlines stop admission and are propagated as native model/tool timeouts by the core. Arbitrary application callbacks are not preempted or sandboxed. A lost scope stops independently running descendants; the root caller detects loss at cooperative boundaries rather than having its application process killed.

Summary

Functions

Returns a specification to start this module under a supervisor.

Accounts legacy tool-contributed usage once, without inventing its model's price.

Replaces the cumulative usage snapshot of one model request.

Types

t()

@type t() :: %ExAgent.ExecutionScope{
  deadline: integer() | nil,
  parent_run_id: String.t() | nil,
  pid: pid(),
  root_run_id: String.t(),
  run_id: String.t(),
  token: reference()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

contribute(scope, id, usage)

Accounts legacy tool-contributed usage once, without inventing its model's price.

record_usage(scope, id, usage, complete? \\ false)

Replaces the cumulative usage snapshot of one model request.