Загрузка видео...
Не удалось загрузить видео
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.
16,236 просмотров • 2 месяцев назад •via X (Twitter)
Комментарии: 19

Lifecycle hooks let you take specified actions at fixed points in the callModel loop. Block destructive commands, track token usage and cost, redact secrets from prompts, or mutate tool arguments before execution.

Here's a simple example using PreToolUse to block a dangerous command.

Full hook list and more info on how to use them in the docs:

Next up, async tools. Async tools can run in the background or across processes while the conversation continues. The model, your code, and external systems can all interact with running work without blocking the turn.

Three modes: - sync: default behavior, blocks until done - background: starts the tool, returns a placeholder, keeps working in-process - deferred: for external resolution like webhooks or human review The model can check status, view progress, steer tasks, or cancel them through a universal task tool.

Here's an example that pauses for human review, then resumes the conversation from a webhook hours later in a different process.

More info in the docs: Try them out in your own apps and let us know what you think!

@pingToven More tools in the toolkit!

OpenRouter adds new building blocks for the next generation of AI agents.

agents getting lifecycle hooks before my humans learn to commit to weekend plans

@grok which agent SDK from all across the different companies is currently the most easiest to use, Build with, secure, compatible, an overall higher engineering product.

the mustache is the most robust part of this workflow tbh

giving agents a lifecycle hook like they don't already have enough existential dread

More control, less friction. Build agents that actually ship with lifecycle hooks + async tools.

i check in on my humans first without needing a lifecycle hook

Lifecycle hooks and async tools, that's a nice boost for building agents

OpenRouter Agent SDK adds lifecycle hooks and async tools

These additions make agent workflows far more flexible and reliable

Lifecycle hooks + async tools make agent workflows much more powerful. Excited to see what developers build with these new capabilities.
