diff --git a/index.js b/index.js index 2123084..a8916e2 100644 --- a/index.js +++ b/index.js @@ -1356,10 +1356,21 @@ export function apply(ctx, config) { ) if (wantsBackground && jobs !== undefined) { + // `owner` is a SESSION ID, not the Agent handle. + // + // The jobs registry resolves an owner through the agent registry — + // `agents.get(session)` — and throws `session "[object Object]" has + // no live agent` for anything else, so passing `exec.agent` here made + // the default `index` call fail outright: it is the one path this + // plugin takes that a caller cannot see fail until the job service is + // present. The agent's own `id` IS the session id (the registry keys + // by it), and a handle without one is registered unowned rather than + // refused. + const owner = exec.agent?.id const jobId = jobs.start({ kind: 'recall-index', label: `recall index ${workspace}`, - ...(exec.agent === undefined ? {} : { owner: exec.agent }), + ...(owner === undefined || owner === null || owner === '' ? {} : { owner }), run: () => { const controller = new AbortController() const done = (async () => {