Shared request lifecycle helpers for non-delegated reasoning strategies.
Summary
Functions
Emits normalized request lifecycle telemetry for a reasoning strategy.
Emits the public request-started signal and matching request telemetry.
Emits the terminal request signal and telemetry when a strategy completes or fails.
Extracts usage accounting from strategy state or its terminal result payload.
Infers a normalized error type atom from common runtime error shapes.
Tracks the active request identifier across non-delegated strategy transitions.
Types
Functions
@spec emit_request_telemetry(atom(), map(), lifecycle_event(), String.t(), keyword()) :: :ok
Emits normalized request lifecycle telemetry for a reasoning strategy.
Callers can override derived metadata such as usage, model, iteration, or
llm call id through opts when the state does not yet contain that data.
Emits the public request-started signal and matching request telemetry.
This is used by non-delegated strategies that own their request lifecycle directly rather than projecting it from worker runtime events.
Emits the terminal request signal and telemetry when a strategy completes or fails.
A terminal event is emitted only on the transition into a completed or error status, and only when a request id can be resolved from state or options.
Extracts usage accounting from strategy state or its terminal result payload.
Infers a normalized error type atom from common runtime error shapes.
This accepts both the new canonical envelope and legacy tuple or map forms that still appear at runtime boundaries during the 2.0 transition.
Tracks the active request identifier across non-delegated strategy transitions.
The request id is retained while the state remains active and is cleared once the strategy reaches a terminal status.