camelAI Documentation

Guides

Human input: approvals, questions, and MCP elicitations in camelRun v2

Pause camelRun v2 runs for human answers, tool approvals, or signed MCP form and URL elicitations, then resume via /v2/agents/:idOrKey/inputs.

View as Markdown

A camelRun v2 run can pause mid-turn and wait for human input without holding an open connection. When paused, the run's status becomes input_required, its inputs array lists the pending PendingInputView record, and an input_required event (and run.input_required webhook) is emitted.

Answering the input resumes the exact paused turn state, even hours later or from a different server process.

Ways a run pauses for input

1. The model asks a question (ask_human)

Include "human" in builtins. When the model needs clarification or confirmation, it calls ask_human({ question, options? }), creating a pending input with kind: "question".

ts
const agent = await client.agents.upsert("ops-assistant", {
  instructions: "Ask the user before choosing a deployment environment.",
  builtins: ["human"],
});

let run = await agent.run("Deploy the latest build.");
if (run.status === "input_required") {
  const pending = run.inputs[0];
  console.log(pending.prompt); // { question: "Which environment?", options: ["staging", "prod"] }

  run = await agent.answerInput(pending.id, {
    approved: true,
    answer: "staging",
  });
}
console.log(run.text);

2. Tool approval (requiresApproval: true)

Mark any custom local or HTTP webhook tool with requiresApproval: true. Before executing the tool, camelRun pauses the run with kind: "approval":

ts
const agent = await client.agents.upsert("billing-agent", {
  instructions: "Help support agents process refunds.",
  tools: [
    {
      name: "issueRefund",
      description: "Refund a charge",
      parameters: {
        type: "object",
        properties: { chargeId: { type: "string" }, amountUsd: { type: "number" } },
        required: ["chargeId", "amountUsd"],
      },
      url: "https://app.example.com/tools/refund",
      requiresApproval: true,
    },
  ],
});

When responding to kind: "approval", you must pass an explicit boolean approved:

  • { approved: true } executes the tool and continues the turn.
  • { approved: false } skips the tool, tells the model the action was denied, and lets the turn continue.

3. Signed MCP approval and elicitation

An MCP server configured with auth: { type: "runtime" } can pause a tool call by returning resultType: "input_required" in its JSON-RPC result with one entry in inputRequests and an optional requestState string (up to 64 KiB):

  • Approval (method: "agent-runtime/approval"): Pauses with kind: "approval". After approval, camelRun re-invokes tools/call with the original agent-runtime/idempotencyKey and a signed approval claim ({ input, by: { id }, at }) in the runtime JWT.
  • Form elicitation (method: "elicitation/create", params: { mode: "form", message, requestedSchema }): Pauses for structured form fields. Submit approved: true with an object in answer (or approved: false to decline). camelRun resumes tools/call with inputResponses: { [key]: { action: "accept" | "decline", content } } and requestState.
  • URL elicitation (method: "elicitation/create", params: { mode: "url", message, url, elicitationId }): Pauses for an out-of-band HTTPS step (for example OAuth or checkout). Resume with approved: true (or false to decline).

Responding to signed MCP inputs requires a tenant API key (cr_live_...). Scoped agent tokens (agt_tok_...) receive 403 forbidden when attempting to answer signed MCP approvals or elicitations. Keep your tenant API key on your server and verify the user's permission before calling POST /v2/agents/:idOrKey/inputs/:inputId.

Listing and answering inputs

List pending inputs

bash
curl -s "https://run.camelai.com/v2/agents/ops-assistant/inputs" \
  -H "Authorization: Bearer $CAMELRUN_API_KEY"

Returns { "runs": [ RunRecord, ... ] } containing every run on the agent with unexpired pending inputs.

Respond to an input

bash
curl -s -X POST "https://run.camelai.com/v2/agents/ops-assistant/inputs/$INPUT_ID" \
  -H "Authorization: Bearer $CAMELRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "approved": true,
    "answer": "staging",
    "wait": true
  }'
FieldTypeNotes
approvedbooleanRequired for kind: "approval". Defaults to true for kind: "question".
answerunknownAnswer payload for ask_human questions or form elicitation (must be a JSON object for MCP form mode).
waitbooleanDefaults to true (waits for the resumed turn to settle). Pass false to return immediately and watch SSE events.
actorstringRequired (with a tenant API key) when the paused run was started with actor. Must match the run's actor, otherwise returns 403 input_actor_mismatch.

Input lifecycle and errors

Each PendingInputView contains { id, runId, toolCallId, kind, prompt, status, expiresAt }.

  • Answering an already resolved input returns 409 input_already_resolved.
  • Answering after expiresAt marks the input expired and returns 410 input_expired.
  • Answering with a mismatched actor or missing tenant credential on an actor-bound run returns 403 input_actor_mismatch.
  • Resolving an input emits input_resolved and run_resumed on the agent's event stream.