Budget checking, callback handling, and fallback recovery for SubAgent execution.
Handles:
- Budget callback/token_limit checking
- Budget exhaustion with fallback attempts
- Last-expression fallback recovery
- Budget introspection maps for Lisp and Elixir callbacks
Summary
Functions
Build budget map for (budget/remaining) Lisp introspection.
Uses hyphenated keys (idiomatic PTC-Lisp/Clojure).
Check if budget is exceeded via callback or token_limit.
Returns :continue or :stop.
Handle budget exceeded — try fallback or return error.
Handle unified budget exhaustion (work + retry turns consumed) with fallback attempt.
Functions
@spec build_introspection_map(PtcRunner.SubAgent.Definition.t(), map()) :: map()
Build budget map for (budget/remaining) Lisp introspection.
Uses hyphenated keys (idiomatic PTC-Lisp/Clojure).
@spec check_callback(map()) :: :continue | :stop
Check if budget is exceeded via callback or token_limit.
Returns :continue or :stop.
@spec handle_exceeded(PtcRunner.SubAgent.Definition.t(), map()) :: {:ok | :error, PtcRunner.Step.t()}
Handle budget exceeded — try fallback or return error.
@spec handle_exhausted_termination(PtcRunner.SubAgent.Definition.t(), map()) :: {:ok | :error, PtcRunner.Step.t()}
Handle unified budget exhaustion (work + retry turns consumed) with fallback attempt.