docs(plugins): an agent.open.before hook starts writes to its own agent without awaiting

An agent.open.before hook that awaits setMetadata (or any write) on the
agent being opened deadlocks: the write joins the agent's lifecycle lane
behind the open, and the open waits on the hook until it times out. The
hooks reference now says so and shows the supported shape, a write
started without awaiting, which runs right after the open.

Deferred, not in this stack: reject such a write immediately instead of
letting the hook time out. The host knows which plugin hook it is
awaiting for the agent and which channel the write arrives on, so the
rejection can be keyed on "this plugin is inside an open hook for this
agent" without cross-process tagging, and an unrelated client's write
would still wait as it does today.
This commit is contained in:
Mohamed Boudra
2026-11-05 21:25:11 +01:00
parent c22b97506f
commit 5828fd5ce4
3 changed files with 25 additions and 0 deletions
+11
View File
@@ -283,6 +283,17 @@ server.addHook("agent.create.after", async ({ agent }) => {
Receives `{ request }`; only `env`, `tools`, and `mcpServers` may change, for this launch. All other fields are read-only. A throw, invalid result, or timeout fails the open.
Do not await a write to the agent being opened, such as `setMetadata`. The write waits for the open to finish, the open waits for your hook, so the hook times out and the open fails. Start the write without awaiting it; it runs right after the open:
```ts
server.addHook("agent.open.before", async ({ request }, { paseo }) => {
void paseo.agents
.ref(request.agentId)
.setMetadata({ "my.plugin": { openedBy: "hook" } })
.catch((error) => console.error(error));
});
```
**`agent.open.before` request example:**
```json