Vibeleaderboard
← All Intel
Intel / post

Agent SDK adds lifecycle hooks and tools that outlive the turn

Source
x.com
Date
OpenRouter@OpenRouter

Introducing two features to the OpenRouter Agent SDK: lifecycle hooks and async tools! If you aren't familiar, the Agent SDK is our toolkit for building agentic applications with OpenRouter. These two additions allow to build even more robust AI workflows.

Context

The two additions to OpenRouter's Agent SDK give developers control over an agent's run at two different points. Lifecycle hooks let their own code step in before or after events such as a , and async tools let a slow tool keep working while the agent carries on. The Agent SDK is OpenRouter's toolkit for building agent applications on its model API, according to the announcement.

The announcement's demo video shows why a matters. A deploy tool can publish an app to either preview or production, and a pre-tool-use hook attached to it makes sure the agent deploys only to preview, so it cannot accidentally ship to production. A post-tool-use hook then displays a message once the deploy finishes. OpenRouter's lifecycle hooks documentation, as read in late October, says a PreToolUse handler can rewrite a tool's arguments before they are validated and run, or block the call and pass its reason back to the model. The same page lists other hook points, including start and end, prompt submission and tool failure.

Async tools address a different problem: a step such as rendering a video can take long enough that waiting on it would stall everything else. In the video's example, a render tool runs in the background while the agent moves on to prepare a social post, and the finished render is reported back to the main workflow. The current async tools documentation describes two modes. A background tool runs in the same , and its result is added to the conversation before the model's next turn. A deferred tool hands the work to an outside system, such as a review queue, and pauses the conversation until some process completes the task, which requires saved state so another process can resume it. The launch post and video show only the background behavior; the deferred mode is described on the current documentation page.

Terms in this piece · Glossary
  • Tool call — Text the model generates in an agreed format that names a tool and gives its inputs.
  • agent hook — A script the harness runs automatically at a fixed point in an agent's loop — before a tool call, after an edit, on session start.
  • Session — One conversation or piece of work as a harness keeps it: a record of messages, tool calls and observations that can be saved and resumed.
  • Process — A running instance of a program, with its own working memory, open files and identity.

Get the Brief

A cited digest of what matters for people building with AI, every morning. Unsubscribe anytime. See today’s edition

More from OpenRouter
Recommended reads