agent-lattice 0.25.0 → 0.26.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 +19 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -701,6 +701,17 @@ the target's lifecycle: an `AgentSpec` spawns a fresh session per call, while an
|
|
|
701
701
|
`AgentLike` target keeps history across calls and is usually not safe to call
|
|
702
702
|
concurrently. *Requires 0.24.0 or later.*
|
|
703
703
|
|
|
704
|
+
For durable child sessions, `AgentToolOptions.prepareTarget` runs after the
|
|
705
|
+
child's input has been validated and mapped to a task, before the child starts.
|
|
706
|
+
It receives the target, task, tool-use ID, parent run ID, trace session ID, and
|
|
707
|
+
abort signal; return the `AgentLike` to call. A host can spawn the supplied
|
|
708
|
+
`AgentSpec` with a per-call `HistoryStore` and return an adapter that records
|
|
709
|
+
its event stream. Without the hook, a spec still spawns a fresh session as
|
|
710
|
+
before. Direct `ask` child trace events share the parent's trace session and
|
|
711
|
+
carry both `parent_run_id` and `parent_tool_use_id`, so concurrent calls to the
|
|
712
|
+
same child can be distinguished. The host owns cleanup if preparing a child
|
|
713
|
+
fails. *Requires 0.26.0 or later.*
|
|
714
|
+
|
|
704
715
|
When concurrency is available, the SDK tells the model to batch independent
|
|
705
716
|
calls and to use separate assistant responses when a later call needs an earlier
|
|
706
717
|
result. Runtime safety checks and `toolBatchPolicy` remain authoritative.
|
|
@@ -1654,3 +1665,11 @@ returns. Both fields are optional and absent when the client does not report
|
|
|
1654
1665
|
them.
|
|
1655
1666
|
|
|
1656
1667
|
*Requires 0.16.0 or later.*
|
|
1668
|
+
|
|
1669
|
+
## Invalid tool argument JSON
|
|
1670
|
+
|
|
1671
|
+
*Requires 0.25.1 or later.*
|
|
1672
|
+
|
|
1673
|
+
When a completed Anthropic-compatible stream contains malformed tool argument JSON, the SDK does not execute the tool. It returns a matching `tool_result` with `is_error: true`, identifies the JSON syntax problem (including a character position when available), lists required top-level fields, and asks the model to regenerate complete arguments from the tool schema. Raw argument excerpts are not echoed in the error.
|
|
1674
|
+
|
|
1675
|
+
Incomplete intermediate chunks are not errors if the final JSON is valid. Valid JSON objects, including `{}`, still go through normal schema validation. Valid JSON values that are not objects are rejected before execution. Existing turn limits still apply; this feedback does not guarantee that a model will correct its response.
|
package/dist/index.d.ts
CHANGED
|
@@ -117,6 +117,7 @@ export type ContextTraceEvent = {
|
|
|
117
117
|
session_id: string;
|
|
118
118
|
run_id: string;
|
|
119
119
|
parent_run_id?: string;
|
|
120
|
+
parent_tool_use_id?: string;
|
|
120
121
|
seq: number;
|
|
121
122
|
source: AgentRuntimeSource;
|
|
122
123
|
type: ContextTraceEventType;
|
|
@@ -298,6 +299,11 @@ export type ToolBatchPolicy<TContext = unknown> = {
|
|
|
298
299
|
export type ToolExecutionContext<TContext = unknown> = {
|
|
299
300
|
signal?: AbortSignal;
|
|
300
301
|
toolUseId: string;
|
|
302
|
+
/** Current agent query, when the tool is called from an agent loop. */
|
|
303
|
+
trace?: {
|
|
304
|
+
sessionId: string;
|
|
305
|
+
runId: string;
|
|
306
|
+
};
|
|
301
307
|
context?: TContext;
|
|
302
308
|
agentRuntime?: AgentRuntimeContext;
|
|
303
309
|
permissions?: RuntimePermissions;
|
|
@@ -853,6 +859,21 @@ export type AgentToolOptions = {
|
|
|
853
859
|
* never shown to the model.
|
|
854
860
|
*/
|
|
855
861
|
metadata?: Record<string, unknown>;
|
|
862
|
+
/**
|
|
863
|
+
* Resolve the child session for this invocation after input validation and
|
|
864
|
+
* task mapping, before the child runs. A host can spawn an AgentSpec with a
|
|
865
|
+
* per-call HistoryStore and return an AgentLike that records its event stream.
|
|
866
|
+
* The default is to spawn a spec or reuse a live AgentLike target.
|
|
867
|
+
*/
|
|
868
|
+
prepareTarget?: (invocation: {
|
|
869
|
+
target: AgentToolTarget;
|
|
870
|
+
toolName: string;
|
|
871
|
+
toolUseId: string;
|
|
872
|
+
task: string | ContentBlock[];
|
|
873
|
+
parentRunId?: string;
|
|
874
|
+
traceSessionId?: string;
|
|
875
|
+
signal?: AbortSignal;
|
|
876
|
+
}) => AgentLike<any> | Promise<AgentLike<any>>;
|
|
856
877
|
/**
|
|
857
878
|
* Expected structured output of the target. When omitted, the declaration is
|
|
858
879
|
* inherited from the target itself (an Agent's or AgentSpec's
|