Human-in-the-loop approval for coding agents
Pause a coding agent before deployment or another risky action. Ask a question through MCP, send the human a browser link and wait for an explicit answer.
The SDK examples use an authenticated SocketHelp client. Set up the SDK or connect your agent over MCP.
Make the decision a separate step
An agent may have enough information to prepare a change without having authority to deploy it. Human-in-the-loop approval separates preparation from execution: the agent explains the intended action, asks a specific question and waits for an authorized person to answer.
Use a question that identifies the environment and action, such as deploying a particular build to staging. Include relevant details and offer a clear defer or deny option. Avoid treating a broad question like “continue?” as permission for several unrelated actions.
Ask, show the link and wait
ask_human creates a question in the workspace and returns an answerUrl. Show that link to the human even when notification email is available. The emailed field says whether notification delivery succeeded; it is not an answer to the question.
Call wait_for_approval with the question id. A pending result, timedOut flag, transport error or expiry means you must keep waiting or stop. Only continue when status is answered and the answer explicitly permits the proposed action. The SDK and CLI expose the same create, inspect and wait operations.
const question = await socket.askHuman({
question: 'Deploy build 42 to staging?',
details: 'Tests passed. This replaces the current staging build.',
options: ['Deploy to staging', 'Wait'], timeoutMinutes: 30,
});
console.log(question.answerUrl);
const result = await socket.waitForApproval(question.id, 20);
if (result.status === 'answered' && result.answer === 'Deploy to staging') {
// Execute only the staging deployment described above.
}The agent cannot answer its own question
Answers require a signed-in browser session belonging to a workspace owner or admin. API keys cannot answer. A copied link does not bypass workspace authorization, and opening the link alone does not submit a decision. The stored answer records who answered and when.
This gives your workflow an explicit decision record. It does not technically prevent an external agent from ignoring the result or using credentials it already holds elsewhere. Your agent instructions and deployment permissions must enforce the same boundary.
Use finite deadlines and a safe fallback
Questions default to a 60-minute lifetime and can last from one minute to one day. Free allows 20 questions a day, Pro 200 and Team 1,000. A single wait lasts no more than 30 seconds, so repeat it while the question remains pending.
If SMTP is unavailable, the answer page still works through the link. If the human is unavailable, leave the prepared work reviewable and stop the dependent action. Never convert silence into approval.