agent-lattice 0.9.20 → 0.9.23
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/README.md +34 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -533,6 +533,40 @@ delivery: the runtime waits for the member's upstream reply, feeds it back to
|
|
|
533
533
|
the lead, and keeps going until the root lead returns the final result or the
|
|
534
534
|
run terminates.
|
|
535
535
|
|
|
536
|
+
After one model response queues one or more handoffs, the SDK does not call the
|
|
537
|
+
lead model again immediately. It first runs those members, collects their
|
|
538
|
+
completed or failed reports, and only then calls the lead again. All handoffs
|
|
539
|
+
from the current tool batch are queued before the lead pauses. The receipt keeps
|
|
540
|
+
`status: "accepted"` for compatibility and also includes `phase: "queued"`,
|
|
541
|
+
`completion_pending: true`, `message_id`, `work_item_id`, and `thread_id`.
|
|
542
|
+
|
|
543
|
+
Accepted handoffs use work-item failure isolation by default. If one member
|
|
544
|
+
returns an agent error such as `MaxTurnsError` or `APIError`, the runtime marks
|
|
545
|
+
that work item `failed`, sends a failure report to the lead, and continues the
|
|
546
|
+
other accepted handoffs. The lead receives successful and failed reports
|
|
547
|
+
together and decides whether to retry, revise the task, accept a partial result,
|
|
548
|
+
or finish. A run-wide `AbortError` still stops the runner; the runtime marks the
|
|
549
|
+
current and remaining accepted work `cancelled` before propagating the abort.
|
|
550
|
+
|
|
551
|
+
Handoff work is serial by default. Set a bounded concurrency limit on the team
|
|
552
|
+
when independent members should run at the same time:
|
|
553
|
+
|
|
554
|
+
```ts
|
|
555
|
+
const team = createTeam({
|
|
556
|
+
name: "research",
|
|
557
|
+
lead,
|
|
558
|
+
members,
|
|
559
|
+
runner: { maxConcurrentWorkItems: 4 },
|
|
560
|
+
});
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
You can also pass `maxConcurrentWorkItems` to `createTeamRunner()`. The limit
|
|
564
|
+
must be a positive integer and defaults to `1`. It applies across different
|
|
565
|
+
member mailboxes; work addressed to the same mailbox remains serial because an
|
|
566
|
+
Agent may keep mutable conversation state. Runtime events are emitted as work
|
|
567
|
+
actually progresses, while the reports injected back into the lead stay in the
|
|
568
|
+
original handoff order.
|
|
569
|
+
|
|
536
570
|
Team member tools can also request explicit shared workspace write grants:
|
|
537
571
|
|
|
538
572
|
```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -53,13 +53,19 @@ export type AgentRuntimeDelegateInput = {
|
|
|
53
53
|
workspaceGrants?: WorkspaceGrantInput[];
|
|
54
54
|
};
|
|
55
55
|
export type AgentRuntimeDelegateResult = {
|
|
56
|
-
status: "completed" | "accepted";
|
|
56
|
+
status: "completed" | "accepted" | "failed";
|
|
57
57
|
content: string;
|
|
58
58
|
request: TeamMessage;
|
|
59
59
|
reply?: TeamMessage;
|
|
60
60
|
result?: SDKResultMessage;
|
|
61
|
+
error?: AgentRuntimeFailure;
|
|
61
62
|
workspaceGrants?: WorkspaceGrant[];
|
|
62
63
|
};
|
|
64
|
+
export type AgentRuntimeFailure = {
|
|
65
|
+
code: "max_turns_exceeded" | "api_error" | "tool_execution_error" | "permission_denied" | "agent_error";
|
|
66
|
+
message: string;
|
|
67
|
+
name: string;
|
|
68
|
+
};
|
|
63
69
|
export type WorkspaceAccess = "read" | "write" | "execute";
|
|
64
70
|
export type WorkspaceGrantInput = {
|
|
65
71
|
root: string;
|
|
@@ -94,6 +100,7 @@ export type AgentRuntimeContext = {
|
|
|
94
100
|
permissions: RuntimePermissions;
|
|
95
101
|
delegate(input: AgentRuntimeDelegateInput): Promise<AgentRuntimeDelegateResult>;
|
|
96
102
|
emit(message: TeamRunnerMessage): void;
|
|
103
|
+
shouldPauseAfterToolBatch?(): boolean;
|
|
97
104
|
};
|
|
98
105
|
export type ContextTraceEventType = "run_start" | "user_message" | "model_request" | "assistant_message" | "tool_use" | "tool_result" | "team_message" | "result" | "error";
|
|
99
106
|
export type ContextTraceEvent = {
|
|
@@ -306,12 +313,17 @@ export type SQLiteMailboxOptions = {
|
|
|
306
313
|
database: SQLiteDatabaseLike;
|
|
307
314
|
tableName?: string;
|
|
308
315
|
};
|
|
316
|
+
export type TeamRunnerConfig = {
|
|
317
|
+
maxDelegateDepth?: number;
|
|
318
|
+
maxConcurrentWorkItems?: number;
|
|
319
|
+
};
|
|
309
320
|
export type TeamOptions = {
|
|
310
321
|
name: string;
|
|
311
322
|
lead: Agent<any>;
|
|
312
323
|
members: TeamMemberDefinition[];
|
|
313
324
|
mailbox?: TeamMailbox;
|
|
314
325
|
exposeLeadMailboxTools?: boolean;
|
|
326
|
+
runner?: TeamRunnerConfig;
|
|
315
327
|
};
|
|
316
328
|
export type Team = {
|
|
317
329
|
name: string;
|
|
@@ -320,6 +332,7 @@ export type Team = {
|
|
|
320
332
|
mailbox: TeamMailbox;
|
|
321
333
|
tools: Array<ToolDefinition<any, any>>;
|
|
322
334
|
memberTools: Record<string, Array<ToolDefinition<any, any>>>;
|
|
335
|
+
readonly runnerOptions?: TeamRunnerConfig;
|
|
323
336
|
send(from: string, to: string, content: string, options?: TeamSendOptions): Promise<TeamMessage>;
|
|
324
337
|
drain(options?: TeamDrainOptions): Promise<TeamDrainResult>;
|
|
325
338
|
query(prompt: string | ContentBlock[], options?: QueryOptions): AsyncGenerator<TeamRunnerMessage>;
|
|
@@ -335,12 +348,11 @@ export type TeamDrainResult = {
|
|
|
335
348
|
failed: number;
|
|
336
349
|
rounds: number;
|
|
337
350
|
};
|
|
338
|
-
export type TeamRunnerOptions = {
|
|
351
|
+
export type TeamRunnerOptions = TeamRunnerConfig & {
|
|
339
352
|
team?: Team;
|
|
340
353
|
root?: AgentLike<any>;
|
|
341
354
|
mailbox?: TeamMailbox;
|
|
342
355
|
source?: AgentRuntimeSource;
|
|
343
|
-
maxDelegateDepth?: number;
|
|
344
356
|
};
|
|
345
357
|
export type TeamRunner = {
|
|
346
358
|
root: AgentLike<any>;
|
|
@@ -442,10 +454,11 @@ export type SDKMessage = SDKSystemInitMessage | SDKStreamEventMessage | SDKAssis
|
|
|
442
454
|
export type TeamRunnerSource = AgentRuntimeSource;
|
|
443
455
|
export type TeamRunnerTeamMessage = {
|
|
444
456
|
type: "team_message";
|
|
445
|
-
subtype: "sent" | "claimed" | "replied" | "followup" | "done" | "failed";
|
|
457
|
+
subtype: "sent" | "claimed" | "replied" | "followup" | "done" | "failed" | "cancelled";
|
|
446
458
|
source: TeamRunnerSource;
|
|
447
459
|
mailbox: string;
|
|
448
460
|
message: TeamMessage;
|
|
461
|
+
error?: AgentRuntimeFailure;
|
|
449
462
|
};
|
|
450
463
|
export type TeamRunnerAgentMessage = {
|
|
451
464
|
type: "agent_message";
|