HeadsUpAI

OpenRouter Agent SDK Adds Human-in-the-Loop Tools to Pause High-Stakes AI Tasks

· Updated

OpenRouter, a unified API platform for accessing hundreds of LLMs, added human-in-the-loop (HITL) tools to its TypeScript-based Agent SDK. The update is part of a broader shift seen in Perplexity's Agent Skills guide, using hooks to decide whether to resolve tasks automatically or pause for review.

As developers move toward production-grade agentic engineering, managing non-deterministic behavior is the primary hurdle. While some platforms are matching OpenAI's automated review modes, OpenRouter's approach gives developers granular control. This mirrors a broader shift toward hardening tools for professional environments seen in Anthropic's Claude Code stability improvements.

Implement these controls by updating the @openrouter/agent package and defining tools with the new HITL hooks. Use onResponseReceived to validate or add metadata before the human's input reaches the model. This ensures that human-supplied data is normalized and policy-compliant before the agent resumes its autonomous loop.

OpenRouter
OpenRouter
@OpenRouter
X

New in the OpenRouter Agent SDK: human-in-the-loop tools. Auto-resolve routine tool calls. Pause high-stakes ones for review. Return a value to keep the agent running. Return null to surface the call to your app for human input. https://t.co/wyGXZu5yaH

2likes
View on X

Still wondering? A few quick answers below.

The OpenRouter Agent SDK is a TypeScript toolkit designed to build multi-turn AI agents using a unified API. It features a core function called callModel that manages the agent loop, allowing models to reason, execute tools, and process results autonomously until a task is finished or a specific stop condition is met.

Human-in-the-loop tools use a specific function called onToolCalled to decide whether an agent should continue or pause. If this function returns a value, the agent resolves the task automatically. If it returns null, the agent loop pauses with a status of awaiting_hitl, allowing a human to review the request before the agent proceeds.

While both features pause execution, they serve different purposes. The requireApproval setting acts as a consent gate to decide if a tool should run at all. In contrast, human-in-the-loop tools pause after the tool logic runs to let a human provide or refine the actual result that the AI model will receive.

The onResponseReceived function is a post-processing trigger that fires after a human provides input for a paused tool call. Developers use it to validate, normalize, or enrich the human response with metadata like timestamps or reviewer IDs. This ensures the data matches the tool expected output schema before it is sent back to the model.

To resume an agent, you must call the callModel function again and provide the human decision as a function_call_output item. This item includes the unique ID of the pending tool call and the stringified result. The SDK then processes this input, potentially through a post-processing hook, and continues the conversation from where it paused.

Share this update