Просмотр исходного кода

docs(host): refresh the stale agentFor resume-on-miss comment

The commands entry's inline comment described the old routing shape
("clients only send a sessionId for a published session") without the
ownership fence that agentFor now applies on every path — the fence's
contract home is the api/commands.ts module JSDoc, so trim the duplicate
and point at the routing shape only, keeping one home per fact.
Tianyi Cui 2 месяцев назад
Родитель
Сommit
e81267945a
1 измененных файлов с 6 добавлено и 3 удалено
  1. 6 3
      packages/host/apiproxy/src/api-proxy.ts

+ 6 - 3
packages/host/apiproxy/src/api-proxy.ts

@@ -1202,13 +1202,16 @@ export function createApiProxy(ctx: Context, defaults: ApiProxyDefaults): ApiPro
           ? undefined
           : (await persistence.list()).find(header => header.id === sessionId)
         if (persistence !== undefined && stored !== undefined) {
-          if (stored.cwd !== cwd) {
-            throw new SessionCwdConflict(sessionId, cwd, stored.cwd)
-          }
           const inspected = await persistence.inspect(sessionId)
+          // Ownership first: explicit-id adoption of a session-backed
+          // subagent must answer `agent-busy` regardless of the requested
+          // cwd (the api/commands.ts contract), not a cwd conflict.
           if (hasSubagentOwner({ header: inspected.meta, events: inspected.events }, undefined)) {
             throw new SubagentSessionOwnership(sessionId)
           }
+          if (inspected.meta.cwd !== cwd) {
+            throw new SessionCwdConflict(sessionId, cwd, inspected.meta.cwd)
+          }
           return (await ctx.agents.resume({
             resumeSessionId: sessionId,
             agentOptions,