agent-lattice 0.21.0 → 0.23.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/README.md +68 -0
- package/dist/index.d.ts +24 -2
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -578,6 +578,26 @@ explicit `outputSchema` still applies. Whenever a schema is in effect, the
|
|
|
578
578
|
generated tool description states that the tool returns the target's
|
|
579
579
|
validated structured output as JSON.
|
|
580
580
|
|
|
581
|
+
Two more contract combinations are pinned down since 0.23.0:
|
|
582
|
+
|
|
583
|
+
- **Target declares no `outputSchema`, `agentTool()` declares one
|
|
584
|
+
explicitly.** Assembly allows it (nothing to cross-check against), and an
|
|
585
|
+
`ask` call validates the child's `structuredResult` against the parent-side
|
|
586
|
+
schema and returns it as JSON. This fits children that end through a custom
|
|
587
|
+
`endTurn` + `structuredResult` tool performing domain validation beyond the
|
|
588
|
+
schema (for example reference truthfulness), with the contract declared by
|
|
589
|
+
the parent alone.
|
|
590
|
+
- **Neither side declares a schema.** When the child ends with a
|
|
591
|
+
`structuredResult`, the `ask` tool result is its JSON as-is (unvalidated)
|
|
592
|
+
instead of falling back to the text content and dropping it. The trust
|
|
593
|
+
level is the same as the text result; the schema's job is validation only,
|
|
594
|
+
not gating the structured channel. This applies on both the direct path and
|
|
595
|
+
the team runtime delegate path.
|
|
596
|
+
|
|
597
|
+
*Behavior change in 0.23.0:* existing code where the child ends with
|
|
598
|
+
`endTurn` + `structuredResult` and the parent declares no schema now receives
|
|
599
|
+
the structured JSON from `ask` instead of the text content.
|
|
600
|
+
|
|
581
601
|
### Typed delegation
|
|
582
602
|
|
|
583
603
|
*Requires 0.21.0 or later.*
|
|
@@ -700,6 +720,46 @@ policy, tool execution is unchanged. A policy prevents known bad combinations
|
|
|
700
720
|
inside one model response, but it does not replace database transactions or
|
|
701
721
|
revision checks against concurrent external updates.
|
|
702
722
|
|
|
723
|
+
## Strict Option Validation And Tool Metadata
|
|
724
|
+
|
|
725
|
+
*Requires 0.22.0 or later.*
|
|
726
|
+
|
|
727
|
+
The option objects of `createAgent()`/`createBareAgent()`/`defineAgent()`
|
|
728
|
+
(`AgentOptions`), `agentTool()` (`AgentToolOptions`), `delegateTool()`
|
|
729
|
+
(`DelegateToolOptions`), and `tool()` (`ToolOptions`) are validated strictly:
|
|
730
|
+
an unknown key throws at assembly time —
|
|
731
|
+
|
|
732
|
+
```
|
|
733
|
+
AgentOptions: unknown option "bogusOption". Check for a typo, or upgrade the SDK if this option was added in a newer version.
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
(`agentTool()`/`delegateTool()` prefix the message with `agentTool("<name>"):` /
|
|
737
|
+
`delegateTool("<name>"):` instead.) The point is to fail fast on the old-SDK +
|
|
738
|
+
new-API combination: before 0.22.0 an unknown option was silently ignored, so
|
|
739
|
+
calling a newer API on an older install "worked" with the feature absent.
|
|
740
|
+
|
|
741
|
+
*Behavior change in 0.22.0:* extra keys that used to be silently ignored —
|
|
742
|
+
for example host fields spread into an options object — now throw. If your
|
|
743
|
+
host assembles options by spreading wider objects, strip the extra fields when
|
|
744
|
+
upgrading.
|
|
745
|
+
|
|
746
|
+
Separately, `ToolOptions.metadata` and `AgentToolOptions.metadata` accept a
|
|
747
|
+
`Record<string, unknown>` that is passed through to `ToolDefinition.metadata`:
|
|
748
|
+
|
|
749
|
+
```ts
|
|
750
|
+
const search = tool(
|
|
751
|
+
"search",
|
|
752
|
+
"Search documents",
|
|
753
|
+
z.object({ query: z.string() }),
|
|
754
|
+
async ({ query }) => ({ content: await documentIndex.search(query) }),
|
|
755
|
+
{ metadata: { contractVersion: 3 } },
|
|
756
|
+
);
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
The SDK never reads or interprets `metadata`, and it is never shown to the
|
|
760
|
+
model — it is host-owned, machine-readable annotation (for example a contract
|
|
761
|
+
version). When not passed, the key is absent from the `ToolDefinition`.
|
|
762
|
+
|
|
703
763
|
## Automatic Context Compaction
|
|
704
764
|
|
|
705
765
|
History only grows, so a long-running agent eventually exceeds the model's
|
|
@@ -1350,6 +1410,14 @@ production hosts should pair write and shell access with a permission callback.
|
|
|
1350
1410
|
Shell redirects to `/dev/null` are treated as discard targets, not workspace
|
|
1351
1411
|
writes.
|
|
1352
1412
|
|
|
1413
|
+
Pass `workspace: false` to opt out of the built-in workspace entirely — no
|
|
1414
|
+
built-in file/shell tools and no workspace prompt section, equivalent to
|
|
1415
|
+
`createBareAgent()` (*requires 0.23.0 or later*). Unlike `createBareAgent()`,
|
|
1416
|
+
the option also works through `defineAgent()`, so
|
|
1417
|
+
`defineAgent({ workspace: false })` spawns bare sessions — handy for
|
|
1418
|
+
typed-delegation specialists that should have no filesystem or shell surface
|
|
1419
|
+
at all.
|
|
1420
|
+
|
|
1353
1421
|
## Multi-turn Session
|
|
1354
1422
|
|
|
1355
1423
|
```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -369,6 +369,11 @@ export type AgentHooks<TContext = unknown> = {
|
|
|
369
369
|
export type ToolHandler<TInput = unknown, TContext = unknown> = (input: TInput, context: ToolExecutionContext<TContext>) => Promise<ToolResult> | ToolResult;
|
|
370
370
|
export type ToolOptions<TInput = unknown> = {
|
|
371
371
|
isConcurrencySafe?: (input: TInput) => boolean;
|
|
372
|
+
/**
|
|
373
|
+
* Host-owned, machine-readable annotations carried on the tool definition.
|
|
374
|
+
* The SDK never reads or interprets it; it is never shown to the model.
|
|
375
|
+
*/
|
|
376
|
+
metadata?: Record<string, unknown>;
|
|
372
377
|
};
|
|
373
378
|
export type ToolDefinition<TInput = unknown, TContext = unknown> = {
|
|
374
379
|
name: string;
|
|
@@ -379,6 +384,8 @@ export type ToolDefinition<TInput = unknown, TContext = unknown> = {
|
|
|
379
384
|
parse(input: unknown): TInput;
|
|
380
385
|
handler: ToolHandler<TInput, TContext>;
|
|
381
386
|
isConcurrencySafe?: (input: TInput) => boolean;
|
|
387
|
+
/** Host-owned annotations passed through from `ToolOptions.metadata`. */
|
|
388
|
+
metadata?: Record<string, unknown>;
|
|
382
389
|
};
|
|
383
390
|
export type ToolConcurrencyMode = "safe" | "all" | "sequential";
|
|
384
391
|
export type ToolConcurrencyOptions = {
|
|
@@ -605,7 +612,13 @@ export type AgentOptions<TContext = unknown> = {
|
|
|
605
612
|
autoCompact?: boolean | AutoCompactOptions;
|
|
606
613
|
toolConcurrency?: ToolConcurrencyOptions;
|
|
607
614
|
skills?: SkillDefinition[];
|
|
608
|
-
|
|
615
|
+
/**
|
|
616
|
+
* Workspace root for the built-in file/shell tools. `false` disables the
|
|
617
|
+
* built-in workspace entirely: no workspace tools, no workspace prompt
|
|
618
|
+
* section — equivalent to `createBareAgent`, and the way to make
|
|
619
|
+
* `defineAgent` spawn bare sessions.
|
|
620
|
+
*/
|
|
621
|
+
workspace?: AgentWorkspaceOptions | false;
|
|
609
622
|
permission?: (request: PermissionRequest) => Promise<PermissionDecision> | PermissionDecision;
|
|
610
623
|
modelClient?: ModelClient;
|
|
611
624
|
tracer?: ContextTracer;
|
|
@@ -821,6 +834,12 @@ export type AgentToolInput = z.infer<typeof agentToolInputSchema>;
|
|
|
821
834
|
export type AgentToolOptions = {
|
|
822
835
|
description: string;
|
|
823
836
|
targetMailboxId?: string;
|
|
837
|
+
/**
|
|
838
|
+
* Host-owned, machine-readable annotations carried on the tool definition
|
|
839
|
+
* (e.g. a contract version). The SDK never reads or interprets it; it is
|
|
840
|
+
* never shown to the model.
|
|
841
|
+
*/
|
|
842
|
+
metadata?: Record<string, unknown>;
|
|
824
843
|
/**
|
|
825
844
|
* Expected structured output of the target. When omitted, the declaration is
|
|
826
845
|
* inherited from the target itself (an Agent's or AgentSpec's
|
|
@@ -832,7 +851,10 @@ export type AgentToolOptions = {
|
|
|
832
851
|
* With the schema in effect, the tool result is the target's validated
|
|
833
852
|
* structured output as JSON; a target that ends without submitting — or
|
|
834
853
|
* submits a payload that fails the schema — produces a `child_output_invalid`
|
|
835
|
-
* tool error the parent can retry.
|
|
854
|
+
* tool error the parent can retry. Without any schema, a `structuredResult`
|
|
855
|
+
* the target produced is still passed through as JSON (same trust level as
|
|
856
|
+
* the text result); schema only adds validation, it does not gate the
|
|
857
|
+
* structured channel.
|
|
836
858
|
*/
|
|
837
859
|
outputSchema?: OutputSchema;
|
|
838
860
|
/**
|