agent-lattice 0.21.0 → 0.22.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 CHANGED
@@ -700,6 +700,46 @@ policy, tool execution is unchanged. A policy prevents known bad combinations
700
700
  inside one model response, but it does not replace database transactions or
701
701
  revision checks against concurrent external updates.
702
702
 
703
+ ## Strict Option Validation And Tool Metadata
704
+
705
+ *Requires 0.22.0 or later.*
706
+
707
+ The option objects of `createAgent()`/`createBareAgent()`/`defineAgent()`
708
+ (`AgentOptions`), `agentTool()` (`AgentToolOptions`), `delegateTool()`
709
+ (`DelegateToolOptions`), and `tool()` (`ToolOptions`) are validated strictly:
710
+ an unknown key throws at assembly time —
711
+
712
+ ```
713
+ AgentOptions: unknown option "bogusOption". Check for a typo, or upgrade the SDK if this option was added in a newer version.
714
+ ```
715
+
716
+ (`agentTool()`/`delegateTool()` prefix the message with `agentTool("<name>"):` /
717
+ `delegateTool("<name>"):` instead.) The point is to fail fast on the old-SDK +
718
+ new-API combination: before 0.22.0 an unknown option was silently ignored, so
719
+ calling a newer API on an older install "worked" with the feature absent.
720
+
721
+ *Behavior change in 0.22.0:* extra keys that used to be silently ignored —
722
+ for example host fields spread into an options object — now throw. If your
723
+ host assembles options by spreading wider objects, strip the extra fields when
724
+ upgrading.
725
+
726
+ Separately, `ToolOptions.metadata` and `AgentToolOptions.metadata` accept a
727
+ `Record<string, unknown>` that is passed through to `ToolDefinition.metadata`:
728
+
729
+ ```ts
730
+ const search = tool(
731
+ "search",
732
+ "Search documents",
733
+ z.object({ query: z.string() }),
734
+ async ({ query }) => ({ content: await documentIndex.search(query) }),
735
+ { metadata: { contractVersion: 3 } },
736
+ );
737
+ ```
738
+
739
+ The SDK never reads or interprets `metadata`, and it is never shown to the
740
+ model — it is host-owned, machine-readable annotation (for example a contract
741
+ version). When not passed, the key is absent from the `ToolDefinition`.
742
+
703
743
  ## Automatic Context Compaction
704
744
 
705
745
  History only grows, so a long-running agent eventually exceeds the model's
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 = {
@@ -821,6 +828,12 @@ export type AgentToolInput = z.infer<typeof agentToolInputSchema>;
821
828
  export type AgentToolOptions = {
822
829
  description: string;
823
830
  targetMailboxId?: string;
831
+ /**
832
+ * Host-owned, machine-readable annotations carried on the tool definition
833
+ * (e.g. a contract version). The SDK never reads or interprets it; it is
834
+ * never shown to the model.
835
+ */
836
+ metadata?: Record<string, unknown>;
824
837
  /**
825
838
  * Expected structured output of the target. When omitted, the declaration is
826
839
  * inherited from the target itself (an Agent's or AgentSpec's