agent-lattice 0.9.18 → 0.9.20

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:
@@ -180,8 +201,17 @@ const agent = createAgent({
180
201
  model: "deepseek-v4-flash",
181
202
  tracer,
182
203
  });
204
+
205
+ try {
206
+ await agent.prompt("Trace this run.", { stream: false });
207
+ } finally {
208
+ await tracer.close?.();
209
+ }
183
210
  ```
184
211
 
212
+ Close or flush the LangSmith tracer before a short-lived test process exits so
213
+ LangSmith receives the final root run patch.
214
+
185
215
  If you prefer explicit values over environment variables, pass them to the SDK
186
216
  tracer. `workspaceId` is optional and only selects a LangSmith workspace; it is
187
217
  not the tracing project name.
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>;
@@ -151,6 +160,7 @@ export type ModelRequest = {
151
160
  tools: ModelToolDefinition[];
152
161
  stream: boolean;
153
162
  outputFormat?: OutputFormat;
163
+ thinkingConfig?: ThinkingConfig;
154
164
  onStreamEvent?: (event: Record<string, unknown>) => void;
155
165
  signal?: AbortSignal;
156
166
  };
@@ -362,6 +372,7 @@ export type AgentOptions<TContext = unknown> = {
362
372
  systemPrompt?: string;
363
373
  maxTokens?: number;
364
374
  maxTurns?: number;
375
+ thinkingConfig?: ThinkingConfig;
365
376
  tools?: Array<ToolDefinition<any, TContext>>;
366
377
  skills?: SkillDefinition[];
367
378
  workspace?: AgentWorkspaceOptions;
@@ -378,6 +389,7 @@ export type AgentWorkspaceToolsOptions = {
378
389
  export type QueryOptions<TContext = unknown> = {
379
390
  stream?: boolean;
380
391
  outputFormat?: OutputFormat;
392
+ thinkingConfig?: ThinkingConfig;
381
393
  signal?: AbortSignal;
382
394
  context?: TContext;
383
395
  agentRuntime?: AgentRuntimeContext;
@@ -385,6 +397,14 @@ export type QueryOptions<TContext = unknown> = {
385
397
  tracer?: ContextTracer;
386
398
  };
387
399
  export type OutputFormat = "json" | BetaJSONOutputFormat;
400
+ export type ThinkingConfig = {
401
+ type: "adaptive";
402
+ } | {
403
+ type: "enabled";
404
+ budgetTokens: number;
405
+ } | {
406
+ type: "disabled";
407
+ };
388
408
  export type SDKSystemInitMessage = {
389
409
  type: "system";
390
410
  subtype: "init";
@@ -517,6 +537,7 @@ export declare function query<TContext = unknown>(params: AgentOptions<TContext>
517
537
  prompt: string;
518
538
  stream?: boolean;
519
539
  outputFormat?: OutputFormat;
540
+ thinkingConfig?: ThinkingConfig;
520
541
  signal?: AbortSignal;
521
542
  context?: TContext;
522
543
  }): AsyncGenerator<SDKMessage>;