Skip to content

pending — suspend and ask a human

Elixir · package toolnexus · SPEC §10

Return a Pending from a tool to park the run until someone answers.

Build the suspension shape by hand: return a %Toolnexus.ToolResult{} whose metadata map carries a :pending key holding a %Toolnexus.Request{id:, kind: "input", prompt:}. The id is the correlation key a resolver (:wait_for or Toolnexus.Agents.Runtime.resume/2) echoes back in its Answer, so generate one you can look up later (a UUID, a database primary key). The wire shape is byte-identical to what every other port’s pending/1 producer builds — only the convenience constructor is missing:

%Toolnexus.ToolResult{
output: "Which environment?",
is_error: true,
metadata: %{pending: %Toolnexus.Request{id: "pnd-1", kind: "input", prompt: "Which environment?"}}
}

Toolnexus.ToolResult.pending?/1 reads it back — see Toolnexus.ToolResult for a full worked example, and :wait_for for the whole suspend/resolve/retry cycle.