agent-lattice 0.9.19 → 0.9.21

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 CHANGED
@@ -82,6 +82,27 @@ When `outputFormat` is set, the SDK sends structured output parameters to the
82
82
  provider and returns the final text unchanged. Parse or validate the returned
83
83
  JSON in your application when you need a typed value.
84
84
 
85
+ Pass `thinkingConfig` on the agent to configure reasoning for every query, or
86
+ on an individual query to override the agent default:
87
+
88
+ ```ts
89
+ const agent = createAgent({
90
+ apiKey: process.env.ANTHROPIC_API_KEY,
91
+ model: "claude-sonnet-4-6",
92
+ thinkingConfig: { type: "adaptive" },
93
+ });
94
+
95
+ const result = await agent.prompt("Solve this carefully.", {
96
+ thinkingConfig: { type: "enabled", budgetTokens: 8_000 },
97
+ });
98
+ ```
99
+
100
+ Use `{ type: "adaptive" }` for models that support adaptive thinking. Use
101
+ `{ type: "enabled", budgetTokens }` for models that require a fixed budget, or
102
+ `{ type: "disabled" }` to omit thinking from the provider request. A fixed
103
+ budget is capped at `maxTokens - 1` to satisfy the Anthropic API constraint.
104
+ When omitted, the SDK does not send a thinking configuration.
105
+
85
106
  ## Multimodal Input
86
107
 
87
108
  Pass Anthropic-compatible content blocks for image or document prompts:
@@ -512,6 +533,14 @@ delivery: the runtime waits for the member's upstream reply, feeds it back to
512
533
  the lead, and keeps going until the root lead returns the final result or the
513
534
  run terminates.
514
535
 
536
+ Accepted handoffs use work-item failure isolation by default. If one member
537
+ returns an agent error such as `MaxTurnsError` or `APIError`, the runtime marks
538
+ that work item `failed`, sends a failure report to the lead, and continues the
539
+ other accepted handoffs. The lead receives successful and failed reports
540
+ together and decides whether to retry, revise the task, accept a partial result,
541
+ or finish. A run-wide `AbortError` still stops the runner; the runtime marks the
542
+ current and remaining accepted work `cancelled` before propagating the abort.
543
+
515
544
  Team member tools can also request explicit shared workspace write grants:
516
545
 
517
546
  ```ts
package/dist/index.d.ts CHANGED
@@ -20,7 +20,16 @@ export type ToolResultBlock = {
20
20
  content: string | ContentBlock[];
21
21
  is_error?: boolean;
22
22
  };
23
- export type ContentBlock = TextBlock | ImageBlock | DocumentBlock | ToolUseBlock | ToolResultBlock;
23
+ export type ThinkingBlock = {
24
+ type: "thinking";
25
+ thinking: string;
26
+ signature: string;
27
+ };
28
+ export type RedactedThinkingBlock = {
29
+ type: "redacted_thinking";
30
+ data: string;
31
+ };
32
+ export type ContentBlock = TextBlock | ImageBlock | DocumentBlock | ToolUseBlock | ToolResultBlock | ThinkingBlock | RedactedThinkingBlock;
24
33
  export type AgentLikeEvent = SDKMessage | TeamRunnerMessage;
25
34
  export type AgentLike<TContext = unknown> = {
26
35
  query(prompt: string | ContentBlock[], options?: QueryOptions<TContext>): AsyncGenerator<AgentLikeEvent>;
@@ -44,13 +53,19 @@ export type AgentRuntimeDelegateInput = {
44
53
  workspaceGrants?: WorkspaceGrantInput[];
45
54
  };
46
55
  export type AgentRuntimeDelegateResult = {
47
- status: "completed" | "accepted";
56
+ status: "completed" | "accepted" | "failed";
48
57
  content: string;
49
58
  request: TeamMessage;
50
59
  reply?: TeamMessage;
51
60
  result?: SDKResultMessage;
61
+ error?: AgentRuntimeFailure;
52
62
  workspaceGrants?: WorkspaceGrant[];
53
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
+ };
54
69
  export type WorkspaceAccess = "read" | "write" | "execute";
55
70
  export type WorkspaceGrantInput = {
56
71
  root: string;
@@ -151,6 +166,7 @@ export type ModelRequest = {
151
166
  tools: ModelToolDefinition[];
152
167
  stream: boolean;
153
168
  outputFormat?: OutputFormat;
169
+ thinkingConfig?: ThinkingConfig;
154
170
  onStreamEvent?: (event: Record<string, unknown>) => void;
155
171
  signal?: AbortSignal;
156
172
  };
@@ -362,6 +378,7 @@ export type AgentOptions<TContext = unknown> = {
362
378
  systemPrompt?: string;
363
379
  maxTokens?: number;
364
380
  maxTurns?: number;
381
+ thinkingConfig?: ThinkingConfig;
365
382
  tools?: Array<ToolDefinition<any, TContext>>;
366
383
  skills?: SkillDefinition[];
367
384
  workspace?: AgentWorkspaceOptions;
@@ -378,6 +395,7 @@ export type AgentWorkspaceToolsOptions = {
378
395
  export type QueryOptions<TContext = unknown> = {
379
396
  stream?: boolean;
380
397
  outputFormat?: OutputFormat;
398
+ thinkingConfig?: ThinkingConfig;
381
399
  signal?: AbortSignal;
382
400
  context?: TContext;
383
401
  agentRuntime?: AgentRuntimeContext;
@@ -385,6 +403,14 @@ export type QueryOptions<TContext = unknown> = {
385
403
  tracer?: ContextTracer;
386
404
  };
387
405
  export type OutputFormat = "json" | BetaJSONOutputFormat;
406
+ export type ThinkingConfig = {
407
+ type: "adaptive";
408
+ } | {
409
+ type: "enabled";
410
+ budgetTokens: number;
411
+ } | {
412
+ type: "disabled";
413
+ };
388
414
  export type SDKSystemInitMessage = {
389
415
  type: "system";
390
416
  subtype: "init";
@@ -422,10 +448,11 @@ export type SDKMessage = SDKSystemInitMessage | SDKStreamEventMessage | SDKAssis
422
448
  export type TeamRunnerSource = AgentRuntimeSource;
423
449
  export type TeamRunnerTeamMessage = {
424
450
  type: "team_message";
425
- subtype: "sent" | "claimed" | "replied" | "followup" | "done" | "failed";
451
+ subtype: "sent" | "claimed" | "replied" | "followup" | "done" | "failed" | "cancelled";
426
452
  source: TeamRunnerSource;
427
453
  mailbox: string;
428
454
  message: TeamMessage;
455
+ error?: AgentRuntimeFailure;
429
456
  };
430
457
  export type TeamRunnerAgentMessage = {
431
458
  type: "agent_message";
@@ -517,6 +544,7 @@ export declare function query<TContext = unknown>(params: AgentOptions<TContext>
517
544
  prompt: string;
518
545
  stream?: boolean;
519
546
  outputFormat?: OutputFormat;
547
+ thinkingConfig?: ThinkingConfig;
520
548
  signal?: AbortSignal;
521
549
  context?: TContext;
522
550
  }): AsyncGenerator<SDKMessage>;