Mojentic.LLM.Tools.RunContext (Mojentic v1.5.0)

Copy Markdown View Source

Context handed to a tool runner (and, optionally, to tools that opt in) for a single batch.

Tools may declare a second arg ctx :: RunContext.t() on their run/2 callback to observe cancellation. The runner inspects the callback's exported arity and passes the context only when the callback was implemented as run/2-with-ctx vs the legacy run/1-shape.

Summary

Functions

Signal cancellation. Subsequent cancelled?/1 checks return true.

Returns true if the cancel ref has been signalled.

Construct a new run context.

Types

t()

@type t() :: %Mojentic.LLM.Tools.RunContext{
  cancel_ref: reference() | nil,
  cancelled?: boolean(),
  correlation_id: String.t() | nil,
  on_call_complete: (Mojentic.LLM.Tools.ToolCallOutcome.t() -> :ok) | nil,
  on_call_start: (Mojentic.LLM.Tools.ToolCallExecution.t() -> :ok) | nil,
  source: String.t() | nil
}

Functions

cancel(arg1)

Signal cancellation. Subsequent cancelled?/1 checks return true.

cancelled?(run_context)

Returns true if the cancel ref has been signalled.

When cancel_ref is an :atomics reference we treat any non-zero value as cancelled. When nil, always returns false.

new(opts \\ [])

Construct a new run context.