What the router asks of a person (or of a policy standing in for one) around each tool call.
A turn that carries interaction: {module, context} in its options makes Mead.Router call this
behaviour for every tool the model asks for, in this order: tool_updated/2 with status
:pending, request_permission/2, and, when the answer is :allow, tool_updated/2 with
register_call/3 and :in_progress (with cancellable: true), the tool itself, then tool_updated/2 with :completed or :failed. A denied
call never reaches the hub; the model receives an error result that says why. A tool the model
named wrongly is reported :failed without asking anyone.
The callbacks run in the process that runs the turn, one call at a time, so request_permission/2
may block for as long as it takes to get an answer. A turn without :interaction never touches
this module.
Summary
Callbacks
Puts a multiple-choice question (the ask_user tool) to the person. Returns the id of the
option they picked, {:error, :expired} when the time ran out and {:error, :no_answer} when
nobody could answer. Like request_permission/2 it may block until there is an answer.
Called once an allowed tool call is running in its own process, before the :in_progress
update, so whoever can cancel the call (by killing pid) knows which process to kill.
Called with each fragment of text a streaming provider produces while it answers, in order. The fragments are a preview of the answer the turn returns; a provider that cannot stream never calls it.
Functions
Whether value is a {module, context} pair whose module implements this behaviour.
Types
Callbacks
@callback ask_choice(context :: term(), choice()) :: {:ok, String.t()} | {:error, :expired | :no_answer}
Puts a multiple-choice question (the ask_user tool) to the person. Returns the id of the
option they picked, {:error, :expired} when the time ran out and {:error, :no_answer} when
nobody could answer. Like request_permission/2 it may block until there is an answer.
Called once an allowed tool call is running in its own process, before the :in_progress
update, so whoever can cancel the call (by killing pid) knows which process to kill.
Called with each fragment of text a streaming provider produces while it answers, in order. The fragments are a preview of the answer the turn returns; a provider that cannot stream never calls it.