PtcRunner.Lisp.Eval.Context (PtcRunner v0.5.1)
View SourceEvaluation context for the Lisp interpreter.
Bundles the parameters that flow through recursive evaluation:
ctx: External data (read-only)user_ns: User namespace (mutable bindings fromdef)env: Lexical environment (variable bindings)tool_exec: Tool executor functionturn_history: Previous turn results for multi-turn loops
Limits
| Field | Default | Hard Cap | Purpose |
|---|---|---|---|
loop_limit | 1,000 | 10,000 | Max loop/recursion iterations |
max_print_length | 2,000 | — | Max chars per println call |
Summary
Functions
Appends a print message to the context.
Appends a tool call record to the context.
Increments the iteration count and checks against the limit.
Merges two contexts, specifically combining prints and tool calls. Used to merge results from parallel execution branches (pmap, pcalls).
Merges new bindings into the environment.
Creates a new evaluation context.
Sets a new loop limit, respecting the hard maximum.
Updates the user namespace in the context.
Types
@type tool_call() :: %{ name: String.t(), args: map(), result: term(), error: String.t() | nil, timestamp: DateTime.t(), duration_ms: non_neg_integer() }
Tool call record for tracing.
Fields:
name: Tool nameargs: Arguments passed to toolresult: Tool resulterror: Error message if tool failedtimestamp: When tool was calledduration_ms: How long tool took
Functions
Appends a print message to the context.
Long messages are truncated to max_print_length characters (default: 2000).
Appends a tool call record to the context.
Increments the iteration count and checks against the limit.
Merges two contexts, specifically combining prints and tool calls. Used to merge results from parallel execution branches (pmap, pcalls).
Merges new bindings into the environment.
Creates a new evaluation context.
Options
:max_print_length- Max characters perprintlncall (default: 2000)
Examples
iex> ctx = PtcRunner.Lisp.Eval.Context.new(%{}, %{}, %{}, fn _, _ -> nil end, [])
iex> ctx.user_ns
%{}
iex> ctx = PtcRunner.Lisp.Eval.Context.new(%{}, %{}, %{}, fn _, _ -> nil end, [], max_print_length: 500)
iex> ctx.max_print_length
500
Sets a new loop limit, respecting the hard maximum.
Updates the user namespace in the context.