Final step assembly for SubAgent execution.
Centralizes the common pattern of enriching a %Step{} with usage metrics,
trace-filtered turns, collected messages, and prompt metadata. Used by both
Loop and Loop.TextMode to construct the step returned from SubAgent.run/2.
Summary
Functions
Finalize a step with metrics, turns, messages, and prompt metadata from state.
Functions
@spec finalize(PtcRunner.Step.t(), map(), keyword()) :: PtcRunner.Step.t()
Finalize a step with metrics, turns, messages, and prompt metadata from state.
Options
:duration_ms— required, total execution duration:memory_bytes— memory used in bytes (default0):turn_offset— offset for turn count, e.g.-1for pre-turn failures (default0):is_error— whether this is an error step, affects trace filtering (defaultfalse):final_turn— a turn to prepend tostate.turnsbefore reversing (defaultnil):final_messages— override for messages (defaultstate.messages):field_descriptions— setstep.field_descriptions(defaultnil, not set):journal— overridestep.journal(defaultnil, not set):summaries— overridestep.summaries(defaultstate.summaries):child_steps— overridestep.child_steps(defaultstate.child_steps):extra_usage— map merged into usage (e.g.%{fallback_used: true})