Run a StaffDeck agent
Prepare
- Require
STAFFDECK_BASE_URL,STAFFDECK_API_KEY, and an accessibleagent_id. - Read references/run-api.md for routes and payloads.
- Generate a unique, stable
Idempotency-Keyfor each logical session or run. Reuse it only to retry the identical request.
Choose session mode
- Use a persistent session when the task may require user clarification, a pending SOP, or follow-up turns.
- Use stateless mode only for an isolated request that must not affect later conversations.
- Reuse the same
session_idfor every continuation of anawaiting_inputrun.
Execute
- For a persistent conversation, create or recover a session with
POST /agents/{agent_id}/sessions. Supply a stableexternal_session_idfrom the caller's system. - For an interactive answer, prefer
POST /agents/{agent_id}/runs:streamand consume SSE in the same request. Retain theX-Run-IDresponse header. - For detached execution, use
POST /agents/{agent_id}/runs, then consumeGET /runs/{run_id}/eventsor pollGET /runs/{run_id}with bounded backoff. - Stop polling at
succeeded,failed,cancelled, orawaiting_input. - Call
/resultonly aftersucceeded. - Preserve
reply,citations,tool_calls,task_results,session_state, andartifactsin the result passed to the caller.
Continue or cancel
- On
awaiting_input, report the requested information and submit the user's answer as a new run in the same session. - On
ACTION_BUDGET_EXHAUSTED, preserve the session and continue only when authorized; do not silently loop forever. - Cancel with
POST /runs/{run_id}:cancelwhen the caller requests cancellation or the result is no longer needed. - Use
Last-Event-IDwhen reconnecting SSE. - Append
run.output.deltacontent in order. Replace the accumulated text whenrun.output.replaceis emitted, and stop display streaming atrun.output.completed.
Evidence and privacy
Treat public Trace as an auditable execution summary, not raw COT. Keep citation metadata attached to the claims it supports. Do not expose masked credentials, sensitive model inputs, or unrelated session data.