@namzu/sdk 12.0.0 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/dist/agents/AbstractAgent.d.ts +20 -0
- package/dist/agents/AbstractAgent.d.ts.map +1 -1
- package/dist/agents/AbstractAgent.js +32 -0
- package/dist/agents/AbstractAgent.js.map +1 -1
- package/dist/agents/lock.d.ts.map +1 -1
- package/dist/agents/lock.js +8 -1
- package/dist/agents/lock.js.map +1 -1
- package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.d.ts +2 -0
- package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.d.ts.map +1 -0
- package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.js +137 -0
- package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.js.map +1 -0
- package/dist/gateway/local.d.ts.map +1 -1
- package/dist/gateway/local.js +25 -1
- package/dist/gateway/local.js.map +1 -1
- package/dist/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.d.ts +2 -0
- package/dist/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.d.ts.map +1 -0
- package/dist/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.js +101 -0
- package/dist/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.js.map +1 -0
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +21 -1
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/types/agent/core.d.ts +21 -0
- package/dist/types/agent/core.d.ts.map +1 -1
- package/dist/types/agent/factory.d.ts +18 -0
- package/dist/types/agent/factory.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agents/AbstractAgent.ts +35 -0
- package/src/agents/lock.ts +10 -1
- package/src/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.ts +175 -0
- package/src/gateway/local.ts +25 -1
- package/src/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.ts +118 -0
- package/src/manager/agent/lifecycle.ts +21 -1
- package/src/types/agent/core.ts +22 -0
- package/src/types/agent/factory.ts +20 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 12.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- be3f345: A fan-out naming the same agent runs every child instead of one.
|
|
8
|
+
|
|
9
|
+
`AgentRegistry` hands out ONE `typedAgent` per registered id, and an agent
|
|
10
|
+
instance refuses a second concurrent `run` — correctly, because its abort
|
|
11
|
+
controller and run id are instance state and two overlapping runs would cancel
|
|
12
|
+
each other. So four `create_task` calls naming the same `agent_id` drove four
|
|
13
|
+
runs at one shell: one produced a result and three died with
|
|
14
|
+
`ConcurrentInvocationError`, while `create_task`'s own description tells a model
|
|
15
|
+
that exactly this fan-out is the thing to do.
|
|
16
|
+
|
|
17
|
+
The remedy was already written down — "a host that wants parallelism constructs
|
|
18
|
+
a second instance" — and was unreachable from delegation, where the definition
|
|
19
|
+
owns the instance and the caller has only an id.
|
|
20
|
+
|
|
21
|
+
`Agent` gains an optional `forRun()`, implemented by `AbstractAgent`, returning
|
|
22
|
+
a fresh shell of the same class built from the same metadata. `AgentManager`
|
|
23
|
+
takes one per spawn. Nothing else about a child was ever shared: its abort
|
|
24
|
+
signal is the task's own, its config is rebuilt per spawn by `configBuilder`,
|
|
25
|
+
and the manager cancels through the task rather than the agent. The shell was
|
|
26
|
+
the last shared thing.
|
|
27
|
+
|
|
28
|
+
`AgentDefinition` also gains `createAgent?`, which wins over `forRun` — for an
|
|
29
|
+
agent that needs real construction arguments, which a metadata-only rebuild
|
|
30
|
+
cannot supply. Most hosts need nothing: agents built on `AbstractAgent` already
|
|
31
|
+
work.
|
|
32
|
+
|
|
33
|
+
The lock is unchanged and still refuses. That refusal is right for a host
|
|
34
|
+
calling `run` twice on one instance on purpose; what changed is that delegation
|
|
35
|
+
no longer does so by accident. Loosening the lock instead would have been the
|
|
36
|
+
smaller diff and the wrong one — the state it guards is genuinely instance
|
|
37
|
+
state, and serialising same-agent spawns behind it would deadlock a child that
|
|
38
|
+
spawns a grandchild of its own id.
|
|
39
|
+
|
|
40
|
+
Its message now names the remedy rather than only the refusal.
|
|
41
|
+
|
|
42
|
+
Found by running a four-way fan-out against the published package, not by a
|
|
43
|
+
test.
|
|
44
|
+
|
|
45
|
+
## 12.0.1
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- 5fe072b: A concurrent fan-out no longer kills most of its own launches.
|
|
50
|
+
|
|
51
|
+
`LocalTaskGateway.createTask` passes a progress tee into `sendMessage`, and that
|
|
52
|
+
callback read `task.taskId` — the `const` that the very same `await` assigns. So
|
|
53
|
+
a child that emitted any run event before `sendMessage` resolved reached that
|
|
54
|
+
line inside the temporal dead zone and threw `Cannot access 'task' before
|
|
55
|
+
initialization`, taking the whole launch down with it.
|
|
56
|
+
|
|
57
|
+
Two things kept it hidden. A single sequential launch usually resolves before
|
|
58
|
+
the child says anything, so the ordering rarely bit. And the throw only happens
|
|
59
|
+
when a progress listener is actually attached — with an empty subscriber set the
|
|
60
|
+
loop body never runs and the dead zone is never entered, which is why no unit
|
|
61
|
+
test caught it. `create_task` attaches one for its idle bound on every blocking
|
|
62
|
+
launch, so production always had one.
|
|
63
|
+
|
|
64
|
+
Under a concurrent fan-out both conditions hold. Observed on the published
|
|
65
|
+
package: four `create_task` calls from one assistant turn — the shape that
|
|
66
|
+
tool's own description tells the model to use — and three of the four died with
|
|
67
|
+
`create_task failed: Cannot access 'task' before initialization`.
|
|
68
|
+
|
|
69
|
+
The tee now reads an id filled in after the spawn resolves, and reports nothing
|
|
70
|
+
before then. That window is not a loss: with no id the caller does not yet hold
|
|
71
|
+
the handle, so no idle bound is running against the task and there is no
|
|
72
|
+
progress to attribute to anyone.
|
|
73
|
+
|
|
74
|
+
Introduced in #130 with the idle-bound work. Found by running a live concurrent
|
|
75
|
+
fan-out against the published package rather than by any test.
|
|
76
|
+
|
|
3
77
|
## 12.0.0
|
|
4
78
|
|
|
5
79
|
### Major Changes
|
|
@@ -23,6 +23,26 @@ export declare abstract class AbstractAgent<TConfig extends BaseAgentConfig = Ba
|
|
|
23
23
|
protected currentRunId?: RunId;
|
|
24
24
|
constructor(metadata: AgentMetadata);
|
|
25
25
|
abstract run(input: AgentInput, config: TConfig, listener?: RunEventListener): Promise<TResult>;
|
|
26
|
+
/**
|
|
27
|
+
* A fresh shell of this agent, for a run that must not share one.
|
|
28
|
+
*
|
|
29
|
+
* See {@link Agent.forRun}. An agent is a shell around metadata — every
|
|
30
|
+
* per-run decision arrives in `config` and `input` — so a second instance
|
|
31
|
+
* costs one object and gives the run its own abort controller and run id,
|
|
32
|
+
* which is precisely what the invocation lock is protecting.
|
|
33
|
+
*
|
|
34
|
+
* Rebuilt from `this.constructor` and `this.metadata`, which covers every
|
|
35
|
+
* agent in this package: they all take metadata and nothing else. A
|
|
36
|
+
* subclass with a different constructor signature will throw here, and the
|
|
37
|
+
* answer to that is `this` — the caller then shares the shell and gets the
|
|
38
|
+
* existing refusal on a concurrent run, which is the behaviour before this
|
|
39
|
+
* existed. Losing parallelism is a worse outcome than not having it; losing
|
|
40
|
+
* the run is not on the table.
|
|
41
|
+
*
|
|
42
|
+
* A host whose agent needs real construction arguments supplies
|
|
43
|
+
* `AgentDefinition.createAgent` instead, which wins over this.
|
|
44
|
+
*/
|
|
45
|
+
forRun(): this;
|
|
26
46
|
/**
|
|
27
47
|
* Acquire the invocation lock to prevent concurrent execution.
|
|
28
48
|
* Returns a Disposable that must be disposed to release the lock.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractAgent.d.ts","sourceRoot":"","sources":["../../src/agents/AbstractAgent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,KAAK,E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|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* A fresh shell of this agent, for a run that must not share one.
|
|
35
|
+
*
|
|
36
|
+
* See {@link Agent.forRun}. An agent is a shell around metadata — every
|
|
37
|
+
* per-run decision arrives in `config` and `input` — so a second instance
|
|
38
|
+
* costs one object and gives the run its own abort controller and run id,
|
|
39
|
+
* which is precisely what the invocation lock is protecting.
|
|
40
|
+
*
|
|
41
|
+
* Rebuilt from `this.constructor` and `this.metadata`, which covers every
|
|
42
|
+
* agent in this package: they all take metadata and nothing else. A
|
|
43
|
+
* subclass with a different constructor signature will throw here, and the
|
|
44
|
+
* answer to that is `this` — the caller then shares the shell and gets the
|
|
45
|
+
* existing refusal on a concurrent run, which is the behaviour before this
|
|
46
|
+
* existed. Losing parallelism is a worse outcome than not having it; losing
|
|
47
|
+
* the run is not on the table.
|
|
48
|
+
*
|
|
49
|
+
* A host whose agent needs real construction arguments supplies
|
|
50
|
+
* `AgentDefinition.createAgent` instead, which wins over this.
|
|
51
|
+
*/
|
|
52
|
+
forRun() {
|
|
53
|
+
try {
|
|
54
|
+
const Ctor = this.constructor;
|
|
55
|
+
return new Ctor(this.metadata);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
this.log.warn('Could not build a per-run shell; concurrent runs of this agent will still be refused', {
|
|
59
|
+
agentId: this.metadata.id,
|
|
60
|
+
error: err instanceof Error ? err.message : String(err),
|
|
61
|
+
});
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
33
65
|
/**
|
|
34
66
|
* Acquire the invocation lock to prevent concurrent execution.
|
|
35
67
|
* Returns a Disposable that must be disposed to release the lock.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractAgent.js","sourceRoot":"","sources":["../../src/agents/AbstractAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAa1D,OAAO,EAAE,SAAS,EAAE,MAAM,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C;YACb,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;YAClC,QAAQ,EAAE,EAAE;SACZ,CAAA;IACF,CAAC;IAES,KAAK,CAAC,SAAS,CAAC,KAAe,EAAE,QAA2B;QACrE,IAAI,CAAC,QAAQ;YAAE,OAAM;QACrB,IAAI,CAAC;YACJ,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,sBAAsB,EAAE;gBACtC,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC;aAC1B,CAAC,CAAA;QACH,CAAC;IACF,CAAC;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../src/agents/lock.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,UAAU;IAC1B,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;CACxB;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;gBAEZ,OAAO,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../src/agents/lock.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,UAAU;IAC1B,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;CACxB;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;gBAEZ,OAAO,EAAE,MAAM;CAc3B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAc;IAC1B,OAAO,CAAC,QAAQ,CAAQ;IAExB;;;OAGG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU;IAcpC;;OAEG;IACH,QAAQ,IAAI,OAAO;CAGnB"}
|
package/dist/agents/lock.js
CHANGED
|
@@ -5,7 +5,14 @@
|
|
|
5
5
|
export class ConcurrentInvocationError extends Error {
|
|
6
6
|
agentId;
|
|
7
7
|
constructor(agentId) {
|
|
8
|
-
|
|
8
|
+
// Names the remedy, because the refusal alone sent readers looking for a
|
|
9
|
+
// concurrency bug in their own code. An agent instance holds per-run
|
|
10
|
+
// state — an abort controller and the run id — so two overlapping runs
|
|
11
|
+
// on one shell would cancel each other; the answer is a second shell,
|
|
12
|
+
// not a second attempt. Delegated spawns get one automatically via
|
|
13
|
+
// `Agent.forRun`, so reaching this from a fan-out means the agent
|
|
14
|
+
// could not be rebuilt and wants `AgentDefinition.createAgent`.
|
|
15
|
+
super(`Agent ${agentId} is already processing. Concurrent invocations of one instance are not allowed, because its abort controller and run id are instance state and two runs would cancel each other. Run a second instance instead — or, for a delegated spawn, give its AgentDefinition a \`createAgent\` factory so each child gets its own.`);
|
|
9
16
|
this.name = 'ConcurrentInvocationError';
|
|
10
17
|
this.agentId = agentId;
|
|
11
18
|
}
|
package/dist/agents/lock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../../src/agents/lock.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAC1C,OAAO,CAAQ;IAExB,YAAY,OAAe;QAC1B,KAAK,
|
|
1
|
+
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../../src/agents/lock.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAC1C,OAAO,CAAQ;IAExB,YAAY,OAAe;QAC1B,yEAAyE;QACzE,qEAAqE;QACrE,uEAAuE;QACvE,sEAAsE;QACtE,mEAAmE;QACnE,kEAAkE;QAClE,gEAAgE;QAChE,KAAK,CACJ,SAAS,OAAO,4TAA4T,CAC5U,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACvB,CAAC;CACD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,cAAc;IAClB,QAAQ,GAAG,KAAK,CAAA;IAExB;;;OAGG;IACH,OAAO,CAAC,OAAe;QACtB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAA;QAC7C,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QAEpB,OAAO;YACN,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE;gBACtB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;YACtB,CAAC;SACD,CAAA;IACF,CAAC;IAED;;OAEG;IACH,QAAQ;QACP,OAAO,IAAI,CAAC,QAAQ,CAAA;IACrB,CAAC;CACD"}
|
package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a-progress-tee-cannot-name-a-task-that-does-not-exist.test.d.ts","sourceRoot":"","sources":["../../../src/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { LocalTaskGateway } from '../local.js';
|
|
3
|
+
/**
|
|
4
|
+
* A child that spoke before its own spawn resolved killed the launch.
|
|
5
|
+
*
|
|
6
|
+
* The progress tee handed to `sendMessage` read `task.taskId` — the `const`
|
|
7
|
+
* that the very same `await` assigns. So any run event emitted by the child
|
|
8
|
+
* before `sendMessage` returned reached that line inside the temporal dead
|
|
9
|
+
* zone and threw `Cannot access 'task' before initialization`, taking the whole
|
|
10
|
+
* `create_task` down with it.
|
|
11
|
+
*
|
|
12
|
+
* It survived review and a full unit suite because a single sequential launch
|
|
13
|
+
* usually resolves before the child says anything. A CONCURRENT fan-out does
|
|
14
|
+
* not — and that is the shape `create_task`'s own description tells the model
|
|
15
|
+
* to use. Observed live on the published package: four launches from one turn,
|
|
16
|
+
* three dead.
|
|
17
|
+
*/
|
|
18
|
+
const RUN = 'run_tee';
|
|
19
|
+
/** Emits a run event DURING the spawn, before it resolves. */
|
|
20
|
+
class TalksDuringSpawn {
|
|
21
|
+
emitsBeforeResolve;
|
|
22
|
+
/** Kept so a test can make the child speak AFTER the spawn resolved too. */
|
|
23
|
+
lastListener;
|
|
24
|
+
constructor(emitsBeforeResolve) {
|
|
25
|
+
this.emitsBeforeResolve = emitsBeforeResolve;
|
|
26
|
+
}
|
|
27
|
+
/** The child says something once the caller holds its handle. */
|
|
28
|
+
speakNow() {
|
|
29
|
+
this.lastListener?.({ type: 'iteration_started', runId: RUN, iteration: 99 });
|
|
30
|
+
}
|
|
31
|
+
async sendMessage(options, _context, listener) {
|
|
32
|
+
this.lastListener = listener;
|
|
33
|
+
// The child is alive and streaming before the caller holds its handle.
|
|
34
|
+
for (let i = 0; i < this.emitsBeforeResolve; i += 1) {
|
|
35
|
+
listener?.({ type: 'iteration_started', runId: RUN, iteration: i });
|
|
36
|
+
}
|
|
37
|
+
await Promise.resolve();
|
|
38
|
+
return {
|
|
39
|
+
taskId: 'task_spoke_early',
|
|
40
|
+
agentId: options.agentId,
|
|
41
|
+
agent: {},
|
|
42
|
+
childAbortController: new AbortController(),
|
|
43
|
+
context: {},
|
|
44
|
+
state: 'completed',
|
|
45
|
+
pendingMessages: [],
|
|
46
|
+
createdAt: 1,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
cancel() { }
|
|
50
|
+
cancelAll() { }
|
|
51
|
+
async continueTask() { }
|
|
52
|
+
queueMessage() { }
|
|
53
|
+
drainMessages() {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
async waitForCompletion() { }
|
|
57
|
+
getInstance() {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
listByParent() {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
listActive() {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
getState() {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
on() { }
|
|
70
|
+
off() { }
|
|
71
|
+
cleanup() { }
|
|
72
|
+
dispose() { }
|
|
73
|
+
}
|
|
74
|
+
function context() {
|
|
75
|
+
return {
|
|
76
|
+
parentRunId: RUN,
|
|
77
|
+
parentAgentId: 'supervisor',
|
|
78
|
+
parentAbortController: new AbortController(),
|
|
79
|
+
depth: 0,
|
|
80
|
+
budgetTracker: { total: 100_000, remaining: 100_000 },
|
|
81
|
+
tenantId: 'tnt_t',
|
|
82
|
+
threadId: 'thd_t',
|
|
83
|
+
sessionId: 'ses_t',
|
|
84
|
+
projectId: 'prj_t',
|
|
85
|
+
parentActor: { kind: 'agent', agentId: 'supervisor', tenantId: 'tnt_t' },
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
describe('a launch survives a child that speaks before the spawn resolves', () => {
|
|
89
|
+
it('does not throw when an event arrives mid-spawn', async () => {
|
|
90
|
+
const gateway = new LocalTaskGateway(new TalksDuringSpawn(3), context());
|
|
91
|
+
// The listener is what makes this reproduce, and its absence is what
|
|
92
|
+
// made the bug invisible for so long: with no progress subscriber the
|
|
93
|
+
// loop body never runs, so `task.taskId` is never evaluated and the
|
|
94
|
+
// dead zone is never entered. `create_task` attaches one for the idle
|
|
95
|
+
// bound on every blocking launch, which is why it bit in production and
|
|
96
|
+
// not in any test.
|
|
97
|
+
gateway.onTaskProgress?.(() => { });
|
|
98
|
+
await expect(gateway.createTask({ agentId: 'worker', prompt: 'go', workingDirectory: '/tmp' })).resolves.toMatchObject({ taskId: 'task_spoke_early' });
|
|
99
|
+
});
|
|
100
|
+
it('still forwards those events to the host listener', async () => {
|
|
101
|
+
// The tee is what broke, not the forwarding. A host watching the child
|
|
102
|
+
// must not lose its early events to this fix.
|
|
103
|
+
const seen = [];
|
|
104
|
+
const gateway = new LocalTaskGateway(new TalksDuringSpawn(3), context(), (e) => {
|
|
105
|
+
seen.push(e.type);
|
|
106
|
+
});
|
|
107
|
+
await gateway.createTask({ agentId: 'worker', prompt: 'go', workingDirectory: '/tmp' });
|
|
108
|
+
expect(seen).toEqual(['iteration_started', 'iteration_started', 'iteration_started']);
|
|
109
|
+
});
|
|
110
|
+
it('reports progress once the task has an id to report it against', async () => {
|
|
111
|
+
// Before the id exists nothing is waiting on the task — the caller does
|
|
112
|
+
// not hold the handle yet — so silence there is correct. What must work
|
|
113
|
+
// is everything after.
|
|
114
|
+
const manager = new TalksDuringSpawn(1);
|
|
115
|
+
const gateway = new LocalTaskGateway(manager, context());
|
|
116
|
+
const progressed = [];
|
|
117
|
+
gateway.onTaskProgress?.((id) => progressed.push(id));
|
|
118
|
+
await gateway.createTask({ agentId: 'worker', prompt: 'go', workingDirectory: '/tmp' });
|
|
119
|
+
// The one emitted mid-spawn is not attributed — there was no id yet.
|
|
120
|
+
expect(progressed).toEqual([]);
|
|
121
|
+
// Now the child speaks with the handle already in the caller's hands,
|
|
122
|
+
// which is the case an idle bound is actually measuring.
|
|
123
|
+
manager.speakNow();
|
|
124
|
+
expect(progressed).toEqual(['task_spoke_early']);
|
|
125
|
+
});
|
|
126
|
+
it('survives a concurrent fan-out, which is how this was found', async () => {
|
|
127
|
+
const gateway = new LocalTaskGateway(new TalksDuringSpawn(2), context());
|
|
128
|
+
// Same reason as above: the live failure came through the idle bound's
|
|
129
|
+
// subscriber, so a fan-out test without one would not reproduce the
|
|
130
|
+
// thing it is named after.
|
|
131
|
+
gateway.onTaskProgress?.(() => { });
|
|
132
|
+
const launched = await Promise.all([1, 2, 3, 4].map(() => gateway.createTask({ agentId: 'worker', prompt: 'go', workingDirectory: '/tmp' })));
|
|
133
|
+
expect(launched).toHaveLength(4);
|
|
134
|
+
expect(launched.every((h) => h.taskId === 'task_spoke_early')).toBe(true);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
//# sourceMappingURL=a-progress-tee-cannot-name-a-task-that-does-not-exist.test.js.map
|
package/dist/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a-progress-tee-cannot-name-a-task-that-does-not-exist.test.js","sourceRoot":"","sources":["../../../src/gateway/__tests__/a-progress-tee-cannot-name-a-task-that-does-not-exist.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAa7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;;;;;;;;;;;GAcG;AAEH,MAAM,GAAG,GAAG,SAAkB,CAAA;AAE9B,8DAA8D;AAC9D,MAAM,gBAAgB;IAIQ;IAH7B,4EAA4E;IACpE,YAAY,CAAmB;IAEvC,YAA6B,kBAA0B;QAA1B,uBAAkB,GAAlB,kBAAkB,CAAQ;IAAG,CAAC;IAE3D,iEAAiE;IACjE,QAAQ;QACP,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAW,CAAC,CAAA;IACvF,CAAC;IAED,KAAK,CAAC,WAAW,CAChB,OAA2B,EAC3B,QAA0B,EAC1B,QAA2B;QAE3B,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAA;QAC5B,uEAAuE;QACvE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACrD,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,EAAW,CAAC,CAAA;QAC7E,CAAC;QACD,MAAM,OAAO,CAAC,OAAO,EAAE,C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EAAE,WAAW,GAAG,sBAAsB,GAAG,gBAAgB,CAAC,EACvF,OAAO,CAAC,EAAE;QAAE,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;KAAE;IAWpD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IA6GjE;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,kBAAkB;IA0BpB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAShD,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlE,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIhC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAK/C;;;;OAIG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKrC,SAAS,IAAI,UAAU,EAAE;IAgBzB;;;;;;;OAOG;IACH,cAAc,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI;IAO9D,eAAe,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,GAAG,MAAM,IAAI;CAMnE"}
|
package/dist/gateway/local.js
CHANGED
|
@@ -36,6 +36,11 @@ export class LocalTaskGateway {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
async createTask(options) {
|
|
39
|
+
// Filled once the spawn resolves. A box rather than a bare binding
|
|
40
|
+
// because the assignment happens AFTER the `await` that the reader is
|
|
41
|
+
// passed into — see the progress tee below for why it cannot simply
|
|
42
|
+
// read the `task` const it is declared beside.
|
|
43
|
+
const launched = {};
|
|
39
44
|
const task = await this.agentManager.sendMessage({
|
|
40
45
|
agentId: options.agentId,
|
|
41
46
|
input: {
|
|
@@ -84,11 +89,30 @@ export class LocalTaskGateway {
|
|
|
84
89
|
// idle bound measures. The event itself is not forwarded — a
|
|
85
90
|
// progress signal that carried the child's output would be a
|
|
86
91
|
// second, undocumented way to read a worker's work.
|
|
92
|
+
//
|
|
93
|
+
// The id comes from `launched.id`, NOT from the `task` const
|
|
94
|
+
// below. This callback is handed to the very `await` that assigns
|
|
95
|
+
// `task`, so a child that emits anything before `sendMessage`
|
|
96
|
+
// resolves reached it inside the temporal dead zone and threw
|
|
97
|
+
// `Cannot access 'task' before initialization` — killing the launch
|
|
98
|
+
// outright.
|
|
99
|
+
//
|
|
100
|
+
// It survived because a single sequential launch usually resolves
|
|
101
|
+
// before the child says anything. A concurrent fan-out does not:
|
|
102
|
+
// with four `create_task` calls from one turn — the shape this
|
|
103
|
+
// tool's own description tells the model to use — the event loop
|
|
104
|
+
// interleaves and three of the four died. Found by running one.
|
|
87
105
|
(event) => {
|
|
88
106
|
this.listener?.(event);
|
|
107
|
+
// No id yet means nothing is waiting on this task: the caller
|
|
108
|
+
// does not hold the handle, so an idle bound cannot be running
|
|
109
|
+
// against it. There is no progress to report to anyone.
|
|
110
|
+
if (launched.id === undefined)
|
|
111
|
+
return;
|
|
89
112
|
for (const notify of this.progressListeners)
|
|
90
|
-
notify(
|
|
113
|
+
notify(launched.id);
|
|
91
114
|
});
|
|
115
|
+
launched.id = task.taskId;
|
|
92
116
|
this.trackedTaskIds.add(task.taskId);
|
|
93
117
|
this.agentManager
|
|
94
118
|
.waitForCompletion(task.taskId)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/gateway/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAW5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,MAAM,OAAO,gBAAgB;IACpB,YAAY,CAA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gBAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnC,CAAC;QACD,OAAO,OAAO,CAAA;IACf,CAAC;IAED;;;;;;;OAOG;IACH,cAAc,CAAC,QAAkC;QAChD,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACpC,OAAO,GAAG,EAAE;YACX,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QACxC,CAAC,CAAA;IACF,CAAC;IAED,eAAe,CAAC,QAAsC;QACrD,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACtC,OAAO,GAAG,EAAE;YACX,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC1C,CAAC,CAAA;IACF,CAAC;CACD;AAED;;;;;;;;;GASG;AACH,SAAS,QAAQ,CAAC,IAAgD;IACjE,OAAO;QACN,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,WAAW,EAAE,IAAI,CAAC,WAAW;KAC7B,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a-fan-out-to-one-agent-id.test.d.ts","sourceRoot":"","sources":["../../../../src/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { ReactiveAgent } from '../../../agents/ReactiveAgent.js';
|
|
3
|
+
import { ToolRegistry } from '../../../registry/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* A fan-out naming the same agent four times ran one child and lost three.
|
|
6
|
+
*
|
|
7
|
+
* `AgentRegistry` hands out ONE `typedAgent` per registered id, and an instance
|
|
8
|
+
* refuses a second concurrent `run` — correctly, because its abort controller
|
|
9
|
+
* and run id are instance state and two overlapping runs would cancel each
|
|
10
|
+
* other. So four `create_task` calls at one specialist produced one result and
|
|
11
|
+
* three `ConcurrentInvocationError`s.
|
|
12
|
+
*
|
|
13
|
+
* The prescribed remedy already existed in the docs — "a host that wants
|
|
14
|
+
* parallelism constructs a second instance" — and was unreachable from
|
|
15
|
+
* delegation, where the definition owns the instance and the caller has only an
|
|
16
|
+
* id. Observed live on published 12.0.1: four launches, three lost.
|
|
17
|
+
*
|
|
18
|
+
* These cover the shell itself. That the manager USES it per spawn is covered
|
|
19
|
+
* where the manager is driven; what has to hold here is that asking for a
|
|
20
|
+
* per-run shell gives you a genuinely separate one.
|
|
21
|
+
*/
|
|
22
|
+
const metadata = {
|
|
23
|
+
id: 'worker',
|
|
24
|
+
name: 'worker',
|
|
25
|
+
version: '1.0.0',
|
|
26
|
+
category: 'general',
|
|
27
|
+
description: 'a worker',
|
|
28
|
+
};
|
|
29
|
+
describe('an agent can hand out a shell a single run has to itself', () => {
|
|
30
|
+
it('returns a different instance', () => {
|
|
31
|
+
const agent = new ReactiveAgent(metadata);
|
|
32
|
+
expect(agent.forRun()).not.toBe(agent);
|
|
33
|
+
});
|
|
34
|
+
it('keeps the identity, because it is the same agent', () => {
|
|
35
|
+
const agent = new ReactiveAgent(metadata);
|
|
36
|
+
const shell = agent.forRun();
|
|
37
|
+
expect(shell.metadata.id).toBe('worker');
|
|
38
|
+
expect(shell.type).toBe(agent.type);
|
|
39
|
+
expect(shell.getCapabilities()).toEqual(agent.getCapabilities());
|
|
40
|
+
});
|
|
41
|
+
it('gives each shell its own invocation lock, which is the whole point', async () => {
|
|
42
|
+
// Locking one must not lock the other. Asserted through the public
|
|
43
|
+
// surface: a run that never settles holds the lock, and a second run on
|
|
44
|
+
// a SEPARATE shell must still be admitted.
|
|
45
|
+
// ONE registered agent, two shells — the registry's shape, and the
|
|
46
|
+
// shape the fan-out actually hits.
|
|
47
|
+
const registered = new ReactiveAgent(metadata);
|
|
48
|
+
const first = registered.forRun();
|
|
49
|
+
const second = registered.forRun();
|
|
50
|
+
// A provider that starts and never finishes, so each run holds its
|
|
51
|
+
// shell's lock for the duration of the assertion.
|
|
52
|
+
const provider = {
|
|
53
|
+
// biome-ignore lint/correctness/useYield: it never produces anything, on purpose
|
|
54
|
+
async *chatStream() {
|
|
55
|
+
await new Promise(() => { });
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
const config = {
|
|
59
|
+
model: 'mock',
|
|
60
|
+
tokenBudget: 10_000,
|
|
61
|
+
timeoutMs: 10_000,
|
|
62
|
+
maxIterations: 2,
|
|
63
|
+
provider,
|
|
64
|
+
tools: new ToolRegistry(),
|
|
65
|
+
systemPrompt: 'hold',
|
|
66
|
+
sessionId: 'ses_fan',
|
|
67
|
+
threadId: 'thd_fan',
|
|
68
|
+
projectId: 'prj_fan',
|
|
69
|
+
tenantId: 'tnt_fan',
|
|
70
|
+
};
|
|
71
|
+
// Start one run on each shell; neither resolves, and neither should
|
|
72
|
+
// refuse. A shared shell would reject the second synchronously.
|
|
73
|
+
const a = first.run({ messages: [], workingDirectory: '/tmp' }, config);
|
|
74
|
+
const b = second.run({ messages: [], workingDirectory: '/tmp' }, config);
|
|
75
|
+
await expect(Promise.race([
|
|
76
|
+
Promise.all([a, b]).then(() => 'settled'),
|
|
77
|
+
new Promise((r) => setTimeout(() => r('still running'), 50)),
|
|
78
|
+
])).resolves.toBe('still running');
|
|
79
|
+
void a.catch(() => { });
|
|
80
|
+
void b.catch(() => { });
|
|
81
|
+
});
|
|
82
|
+
it('a definition may override the shell with its own factory', () => {
|
|
83
|
+
// The escape hatch for an agent that needs real construction
|
|
84
|
+
// arguments, which `forRun`'s metadata-only rebuild cannot supply.
|
|
85
|
+
let built = 0;
|
|
86
|
+
const definition = {
|
|
87
|
+
info: { ...metadata, tools: [], defaults: {} },
|
|
88
|
+
typedAgent: new ReactiveAgent(metadata),
|
|
89
|
+
createAgent: () => {
|
|
90
|
+
built += 1;
|
|
91
|
+
return new ReactiveAgent(metadata);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
const one = definition.createAgent?.();
|
|
95
|
+
const two = definition.createAgent?.();
|
|
96
|
+
expect(built).toBe(2);
|
|
97
|
+
expect(one).not.toBe(two);
|
|
98
|
+
expect(one).not.toBe(definition.typedAgent);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=a-fan-out-to-one-agent-id.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a-fan-out-to-one-agent-id.test.js","sourceRoot":"","sources":["../../../../src/manager/agent/__tests__/a-fan-out-to-one-agent-id.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAGzD;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,QAAQ,GAAG;IAChB,EAAE,EAAE,QAAQ;IACZ,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,UAAU;CACvB,CAAA;AAED,QAAQ,CAAC,0DAA0D,EAAE,GAAG,EAAE;IACzE,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACvC,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAA;QAEzC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC3D,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,QAAQ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B,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAehD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAIlD,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAI5D,YAAY,CAAC,WAAW,EAAE,KAAK,GAAG,SAAS,EAAE;IAI7C,UAAU,IAAI,SAAS,EAAE;IAIzB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIpD,WAAW,IAAI,aAAa;IAI5B,EAAE,CAAC,QAAQ,EAAE,sBAAsB,GAAG,IAAI;IAI1C,GAAG,CAAC,QAAQ,EAAE,sBAAsB,GAAG,IAAI;IAK3C,OAAO,IAAI,IAAI;IAUf,OAAO,IAAI,IAAI;IAgBf;;;;;;;;;;;;;OAaG;YACW,cAAc;YA0Bd,sBAAsB;YA4MtB,QAAQ;IAqBtB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;YAuBX,aAAa;IAgG3B;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,aAAa;IAoBrB,OAAO,CAAC,UAAU;YA8CJ,cAAc;IAsB5B,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,IAAI;IAaZ,OAAO,CAAC,YAAY;CAYpB;AA+CD,OAAO,EAAE,0BAA0B,EAAE,CAAA"}
|
|
@@ -34,7 +34,27 @@ export class AgentManager {
|
|
|
34
34
|
if (options.tenantId !== context.tenantId) {
|
|
35
35
|
throw new Error(`Tenant mismatch: options.tenantId=${options.tenantId} differs from context.tenantId=${context.tenantId}. Cross-tenant spawn rejected (Convention #17).`);
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
// A shell this task has to itself, not the registry's shared instance.
|
|
38
|
+
//
|
|
39
|
+
// `resolve` returns one `typedAgent` per registered id, and an instance
|
|
40
|
+
// refuses a second concurrent `run` because it holds per-run state. So
|
|
41
|
+
// a fan-out naming the same `agent_id` four times drove four runs at one
|
|
42
|
+
// shell: one worked and three died with `ConcurrentInvocationError` —
|
|
43
|
+
// while `create_task`'s own description tells the model that this
|
|
44
|
+
// fan-out is the thing to do. Observed live on 12.0.1, four launches,
|
|
45
|
+
// three lost.
|
|
46
|
+
//
|
|
47
|
+
// The remedy was already written down — "a host that wants parallelism
|
|
48
|
+
// constructs a second instance" — and was unreachable here, because the
|
|
49
|
+
// definition owns the instance and this path only has an id.
|
|
50
|
+
//
|
|
51
|
+
// Nothing else about the child is shared: its abort signal is the task's
|
|
52
|
+
// own (`input.signal` below), its config is rebuilt per spawn by
|
|
53
|
+
// `configBuilder`, and the manager cancels through the task rather than
|
|
54
|
+
// the agent. The shell was the only shared thing left.
|
|
55
|
+
const definitionForSpawn = this.registry.getOrThrow(options.agentId);
|
|
56
|
+
const sharedAgent = definitionForSpawn.typedAgent;
|
|
57
|
+
const agent = definitionForSpawn.createAgent?.() ?? sharedAgent.forRun?.() ?? sharedAgent;
|
|
38
58
|
const childAbortController = createChildAbortController(context.parentAbortController);
|
|
39
59
|
// The allocation is computed INSIDE the spawn lock, not here. Reading
|
|
40
60
|
// the parent's remaining budget at this point and debiting it after
|