Per-turn runtime context.
Context is passed between runtime, router, prompt rendering, handlers, and action execution. It keeps dependencies explicit without pushing the entire host application into each function signature.
Summary
Functions
Marks the context as halted.
Returns the Run that owns lifecycle values staged through this context.
Adds an error entry to the context.
Adds a trace entry to the context.
Types
@type t() :: %Spectre.Context{ agent: module(), assigns: map(), errors: [term()], halted?: boolean(), input: Spectre.Input.t(), memory: term(), opts: keyword(), route: Spectre.Route.t() | nil, state: Spectre.State.t(), traces: [term()] }
Functions
Marks the context as halted.
ctx = Spectre.Context.halt(ctx)
Returns the Run that owns lifecycle values staged through this context.
Subject-scoped Spectre.Instance calls opt into per-Run lifecycle
ownership. Stateless Runtime calls and conversation Sessions return nil
and keep the legacy single-lifecycle contract. Extension-owned Effect
builders should bind this value to every staged Effect and use the scoped
Spectre.State lifecycle queries with the same value.
Adds an error entry to the context.
ctx = Spectre.Context.put_error(ctx, {:adapter_failed, reason})
Adds a trace entry to the context.
ctx = Spectre.Context.put_trace(ctx, {:router, :accepted})