diff --git a/packages/server/src/server/agent/agent-loading.ts b/packages/server/src/server/agent/agent-loading.ts index b846635a9b..81afde5c36 100644 --- a/packages/server/src/server/agent/agent-loading.ts +++ b/packages/server/src/server/agent/agent-loading.ts @@ -134,8 +134,10 @@ export async function ensureAgentLoaded( } // Known gap: `record` was read before this create, and createAgent deletes the stored // state outside the agent's lifecycle lane. A setMetadata that saves between the read and - // the delete is overwritten by this stale metadata. The fix is to read and delete the - // stored record inside the lane (createAgentInternal), which is a lifecycle change. + // the delete is overwritten by this stale metadata. That window spans everything from the + // read to the delete, including the agent.create.before hook, which a plugin can hold + // open. The fix is to read and delete the stored record inside the lane + // (createAgentInternal), which is a lifecycle change. snapshot = await deps.agentManager.createAgent(config, agentId, { labels: record.labels, metadata: record.metadata,