agent-lattice 0.20.0 → 0.21.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 +61 -5
- package/dist/index.d.ts +29 -6
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -534,9 +534,15 @@ Unlike `outputFormat` (which relies on the provider's
|
|
|
534
534
|
`submit_output` only requires a model that can call tools, so it ports to any
|
|
535
535
|
tool-capable provider.
|
|
536
536
|
|
|
537
|
-
The same schema composes with `agentTool()` for parent/child delegation:
|
|
538
|
-
it to the child agent and
|
|
539
|
-
|
|
537
|
+
The same schema composes with `agentTool()` for parent/child delegation: give
|
|
538
|
+
it to the child agent, and an `ask` call returns the child's validated output
|
|
539
|
+
as a JSON string. Since 0.21.0 the parent side inherits the child's declared
|
|
540
|
+
schema, so the `agentTool()` copy can be omitted. Passing
|
|
541
|
+
`AgentToolOptions.outputSchema` explicitly is still allowed, but it must match
|
|
542
|
+
the target's declaration (compared by reference, then by derived JSON Schema
|
|
543
|
+
structure) — a mismatch throws at assembly time, so drift fails fast instead
|
|
544
|
+
of at call time. The error message suggests sharing one schema instance or
|
|
545
|
+
omitting the `agentTool()` copy:
|
|
540
546
|
|
|
541
547
|
```ts
|
|
542
548
|
import { agentTool, createAgent } from "agent-lattice";
|
|
@@ -552,16 +558,66 @@ const parent = createAgent({
|
|
|
552
558
|
tools: [
|
|
553
559
|
agentTool("review", child, {
|
|
554
560
|
description: "Ask the reviewer to audit a change.",
|
|
555
|
-
outputSchema
|
|
561
|
+
// outputSchema is inherited from the child (0.21.0+); an explicit copy
|
|
562
|
+
// must match the child's declaration or agentTool() throws.
|
|
556
563
|
}),
|
|
557
564
|
],
|
|
558
565
|
});
|
|
559
566
|
```
|
|
560
567
|
|
|
561
568
|
If the child ends without submitting or submits a payload that fails the
|
|
562
|
-
|
|
569
|
+
schema, the tool returns an `is_error` `tool_result` starting with
|
|
563
570
|
`child_output_invalid:`, so the parent model sees the failure and can retry.
|
|
564
571
|
|
|
572
|
+
*Behavior change in 0.21.0:* where the child declares an `outputSchema` and
|
|
573
|
+
the parent does not, the `ask` tool result changed from the fixed text
|
|
574
|
+
`"Structured output submitted."` to the validated JSON. That is the intended
|
|
575
|
+
fix and ships in a minor under 0.x. Host-defined `AgentLike` adapters carry no
|
|
576
|
+
readable declaration, so nothing is inherited or cross-checked for them; an
|
|
577
|
+
explicit `outputSchema` still applies. Whenever a schema is in effect, the
|
|
578
|
+
generated tool description states that the tool returns the target's
|
|
579
|
+
validated structured output as JSON.
|
|
580
|
+
|
|
581
|
+
### Typed delegation
|
|
582
|
+
|
|
583
|
+
*Requires 0.21.0 or later.*
|
|
584
|
+
|
|
585
|
+
`AgentToolOptions.inputSchema` replaces the default `{mode, task,
|
|
586
|
+
expectedOutput, acceptanceCriteria, workspaceGrants}` input shape with your
|
|
587
|
+
own schema (a zod schema works directly), and `mapInput` projects the
|
|
588
|
+
validated input into the child prompt:
|
|
589
|
+
|
|
590
|
+
```ts
|
|
591
|
+
const judge = createAgent({
|
|
592
|
+
model: "claude-sonnet-4-5",
|
|
593
|
+
systemPrompt: "You judge a case and submit a structured verdict.",
|
|
594
|
+
outputSchema: verdictSchema,
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
const judgeTool = agentTool("judge", judge, {
|
|
598
|
+
description: "Judge a case from its summary and documents.",
|
|
599
|
+
inputSchema: z.object({
|
|
600
|
+
caseSummary: z.string(),
|
|
601
|
+
documents: z.array(z.object({ title: z.string(), content: z.string() })),
|
|
602
|
+
}),
|
|
603
|
+
mapInput: input => renderJudgeTask(input.caseSummary, input.documents),
|
|
604
|
+
});
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
- The parent's arguments are parsed against `inputSchema` before anything
|
|
608
|
+
runs; invalid input is rejected as an error `tool_result` in the parent's
|
|
609
|
+
loop — the same semantics as a plain `tool()` call — and the child is never
|
|
610
|
+
invoked.
|
|
611
|
+
- `inputSchema` and `mapInput` must come as a pair: `agentTool()` throws at
|
|
612
|
+
assembly time when one is missing.
|
|
613
|
+
- Typed delegation is ask-only: there is no `mode` field and no
|
|
614
|
+
`workspaceGrants`.
|
|
615
|
+
- `mapInput` may return a string or `ContentBlock[]`; `ContentBlock[]` is only
|
|
616
|
+
supported for direct `ask` calls — inside a team runtime the projected
|
|
617
|
+
prompt must be a string, or the call fails at runtime.
|
|
618
|
+
- Because typed input no longer matches `AgentToolInput`, `agentTool()` now
|
|
619
|
+
returns `ToolDefinition<any>`.
|
|
620
|
+
|
|
565
621
|
## Concurrent Tool Calls
|
|
566
622
|
|
|
567
623
|
The model requests concurrency by returning multiple `tool_use` blocks in one
|
package/dist/index.d.ts
CHANGED
|
@@ -822,13 +822,34 @@ export type AgentToolOptions = {
|
|
|
822
822
|
description: string;
|
|
823
823
|
targetMailboxId?: string;
|
|
824
824
|
/**
|
|
825
|
-
* Expected structured output of the target
|
|
826
|
-
* the target
|
|
827
|
-
*
|
|
828
|
-
* target
|
|
829
|
-
*
|
|
825
|
+
* Expected structured output of the target. When omitted, the declaration is
|
|
826
|
+
* inherited from the target itself (an Agent's or AgentSpec's
|
|
827
|
+
* `AgentOptions.outputSchema`); when passed explicitly it must match the
|
|
828
|
+
* target's declaration or `agentTool()` throws at assembly time. Host-defined
|
|
829
|
+
* AgentLike adapters carry no readable declaration, so nothing is inherited
|
|
830
|
+
* or cross-checked for them.
|
|
831
|
+
*
|
|
832
|
+
* With the schema in effect, the tool result is the target's validated
|
|
833
|
+
* structured output as JSON; a target that ends without submitting — or
|
|
834
|
+
* submits a payload that fails the schema — produces a `child_output_invalid`
|
|
835
|
+
* tool error the parent can retry.
|
|
830
836
|
*/
|
|
831
837
|
outputSchema?: OutputSchema;
|
|
838
|
+
/**
|
|
839
|
+
* Typed delegation: replaces the default `{mode, task, ...}` input shape
|
|
840
|
+
* with this schema (same structural shape as OutputSchema; a zod schema
|
|
841
|
+
* works directly). The parent's arguments are validated before the child is
|
|
842
|
+
* invoked, and `mapInput` projects the validated input into the child
|
|
843
|
+
* prompt. Typed delegation is ask-only: there is no `mode` field and no
|
|
844
|
+
* `workspaceGrants`. Requires `mapInput`.
|
|
845
|
+
*/
|
|
846
|
+
inputSchema?: OutputSchema;
|
|
847
|
+
/**
|
|
848
|
+
* Projects validated `inputSchema` input into the child prompt. Returning
|
|
849
|
+
* `ContentBlock[]` is only supported for direct ask calls; inside a team
|
|
850
|
+
* runtime the projected prompt must be a string.
|
|
851
|
+
*/
|
|
852
|
+
mapInput?: (input: any) => string | ContentBlock[];
|
|
832
853
|
};
|
|
833
854
|
/**
|
|
834
855
|
* An AgentLike is a live session: it keeps its conversation history across
|
|
@@ -837,7 +858,7 @@ export type AgentToolOptions = {
|
|
|
837
858
|
* continuity.
|
|
838
859
|
*/
|
|
839
860
|
export type AgentToolTarget = AgentLike<any> | AgentSpec<any>;
|
|
840
|
-
export declare function agentTool(name: string, agent: AgentToolTarget, options: AgentToolOptions): ToolDefinition<
|
|
861
|
+
export declare function agentTool(name: string, agent: AgentToolTarget, options: AgentToolOptions): ToolDefinition<any>;
|
|
841
862
|
export declare function delegateTool(name: string, description: string, agent: AgentToolTarget, options?: DelegateToolOptions): ToolDefinition<{
|
|
842
863
|
task: string;
|
|
843
864
|
}>;
|
|
@@ -987,6 +1008,8 @@ declare class Agent<TContext = unknown> {
|
|
|
987
1008
|
*/
|
|
988
1009
|
replaceHistory(messages: ModelMessage[]): Promise<void>;
|
|
989
1010
|
addTools(tools: Array<ToolDefinition<any, TContext>>): void;
|
|
1011
|
+
/** The structured output contract declared via `AgentOptions.outputSchema`, if any. */
|
|
1012
|
+
get outputSchema(): OutputSchema | undefined;
|
|
990
1013
|
private initMessage;
|
|
991
1014
|
private resultMessage;
|
|
992
1015
|
private modelTools;
|