Agentic.Loop.Context
(agentic v0.2.2)
Copy Markdown
Shared state threaded through all loop stages.
Contains everything a stage might need: messages, tools, identity info, resolved model, progress tracking, callbacks, and configuration.
Summary
Functions
Emit an event to the caller and optional on_event callback.
Create a new context from keyword opts.
Track cost and token usage from an LLM response.
Types
@type t() :: %Agentic.Loop.Context{ accumulated_text: String.t(), activation: map(), backend_config: map(), callbacks: map(), caller: pid() | nil, commitment_continuations: non_neg_integer(), config: map(), context_pct: float(), core_tools: [map()], file_reads: %{ required(String.t()) => %{ hash: String.t(), last_read_turn: non_neg_integer() } }, human_input: String.t() | nil, last_response: Agentic.LLM.Response.t() | nil, messages: [map()], metadata: map(), mode: :agentic | :agentic_planned | :turn_by_turn | :conversational, model_filter: :free_only | nil, model_preference: :optimize_price | :optimize_speed, model_selection_mode: :manual | :auto, model_tier: atom(), parent_session_id: String.t() | nil, pending_human_response: boolean(), pending_tool_calls: [map()], phase: atom(), plan: map() | nil, plan_step_index: non_neg_integer(), plan_steps_completed: [non_neg_integer()], profile: atom(), protocol_module: module() | nil, protocol_name: atom(), protocol_session_id: String.t() | nil, reentry_pipeline: (t() -> term()) | nil, resolved_model: map() | nil, session_id: String.t() | nil, stable_prefix_hash: String.t() | nil, strategy: atom(), subagent_budget: float() | nil, subagent_depth: non_neg_integer(), summary_nudge_sent: boolean(), tool_permissions: %{required(String.t()) => :auto | :approve | :deny}, tools: [map()], total_cost: float(), total_tokens: non_neg_integer(), transport_type: Agentic.Protocol.transport_type(), turns_used: non_neg_integer(), user_id: String.t() | nil, workspace_snapshot: String.t() | nil }