agent-lattice 0.23.0 → 0.25.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 +35 -2
- package/dist/index.d.ts +24 -0
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -227,8 +227,10 @@ await agent.prompt("Remember that my name is Ada.");
|
|
|
227
227
|
Each JSONL entry includes `session_id`, `run_id`, `seq`, `source`, `type`, and
|
|
228
228
|
`data`. Agent runs record transcript and context events such as `run_start`,
|
|
229
229
|
`user_message`, `model_request`, `assistant_message`, `tool_use`,
|
|
230
|
-
`tool_result`, and `result`.
|
|
231
|
-
|
|
230
|
+
`tool_result`, and `result`. When the model client reports token usage,
|
|
231
|
+
`assistant_message` events carry it as `data.message.usage`, and the `result`
|
|
232
|
+
event carries the query's summed usage as `data.usage` (since 0.23.1). For
|
|
233
|
+
team runners, pass the tracer per query to propagate it into delegated agents:
|
|
232
234
|
|
|
233
235
|
```ts
|
|
234
236
|
for await (const event of team.query("Ask engineering to investigate.", {
|
|
@@ -316,6 +318,13 @@ root and share one trace session. Each Agent keeps its own SDK session identity,
|
|
|
316
318
|
recorded as `agent_session_id` metadata, so tracing does not change Agent state
|
|
317
319
|
or returned SDK messages.
|
|
318
320
|
|
|
321
|
+
When the model client reports token usage, each `llm` run ends with
|
|
322
|
+
`usage_metadata` in its outputs (`input_tokens`, `output_tokens`,
|
|
323
|
+
`total_tokens`, plus cache buckets under `input_token_details`), so LangSmith
|
|
324
|
+
shows token consumption and inferred cost per model turn. Anthropic cache
|
|
325
|
+
tokens are additive, so they are summed into `input_tokens` the same way
|
|
326
|
+
LangSmith's own Anthropic wrapper does. *Requires 0.23.1 or later.*
|
|
327
|
+
|
|
319
328
|
## Langfuse Context Tracing
|
|
320
329
|
|
|
321
330
|
*Requires 0.19.0 or later.*
|
|
@@ -389,6 +398,13 @@ as child `generation` observations and SDK tool calls as child `tool`
|
|
|
389
398
|
observations. For a `Team` query, delegated runs nest as child `chain`
|
|
390
399
|
observations under the team root, so one handoff invocation stays one trace.
|
|
391
400
|
|
|
401
|
+
When the model client reports token usage, each `generation` observation ends
|
|
402
|
+
with `usageDetails` (`input`, `output`, `cache_creation_input_tokens`,
|
|
403
|
+
`cache_read_input_tokens`, `total`), so Langfuse shows token consumption and
|
|
404
|
+
inferred cost per model turn. Anthropic `input_tokens` already excludes cache
|
|
405
|
+
tokens, matching Langfuse's mutually-exclusive usage buckets. *Requires 0.23.1
|
|
406
|
+
or later.*
|
|
407
|
+
|
|
392
408
|
`startObservation` defaults to the bundled `@langfuse/tracing` function; pass
|
|
393
409
|
`startObservation` only to inject a custom runtime or a test fake.
|
|
394
410
|
|
|
@@ -528,6 +544,15 @@ The structure is enforced by the harness, not by prompt discipline:
|
|
|
528
544
|
- The name is reserved: registering your own `submit_output` tool while
|
|
529
545
|
`outputSchema` is set throws from `createAgent`/`addTools`.
|
|
530
546
|
|
|
547
|
+
By default a valid submission ends the run immediately — the bounded, cheapest
|
|
548
|
+
behavior for schema-delivering workers. For human-facing sessions that should
|
|
549
|
+
close with a natural-language summary, set `submitOutputEndTurn: false`: the
|
|
550
|
+
submission is recorded (re-submitting revises it, last one wins), the tool
|
|
551
|
+
result goes back to the model, and the run ends when the model stops. A text
|
|
552
|
+
ending after a submission succeeds with the last submission as
|
|
553
|
+
`structuredResult`; ending without any submission still fails with
|
|
554
|
+
`error_missing_output`. *Requires 0.25.0 or later.*
|
|
555
|
+
|
|
531
556
|
Unlike `outputFormat` (which relies on the provider's
|
|
532
557
|
`response_format`/`json_schema` support — DeepSeek ignores it, see
|
|
533
558
|
[Provider Compatibility](https://docs.claude-code-sdk.com/reference/provider-compatibility/)),
|
|
@@ -668,6 +693,14 @@ an `isConcurrencySafe` declaration stay sequential. Use `mode: "all"` only when
|
|
|
668
693
|
every tool in the Agent is safe to overlap. Use `mode: "sequential"` to disable
|
|
669
694
|
tool concurrency even for tools marked safe.
|
|
670
695
|
|
|
696
|
+
`agentTool()` accepts the same declaration as `AgentToolOptions.isConcurrencySafe`,
|
|
697
|
+
so a supervisor can fan out independent delegations in one turn. The input the
|
|
698
|
+
predicate receives is the tool's parsed input — the `inputSchema`-validated
|
|
699
|
+
value for typed delegation, the `AgentToolInput` shape otherwise. Keep in mind
|
|
700
|
+
the target's lifecycle: an `AgentSpec` spawns a fresh session per call, while an
|
|
701
|
+
`AgentLike` target keeps history across calls and is usually not safe to call
|
|
702
|
+
concurrently. *Requires 0.24.0 or later.*
|
|
703
|
+
|
|
671
704
|
When concurrency is available, the SDK tells the model to batch independent
|
|
672
705
|
calls and to use separate assistant responses when a later call needs an earlier
|
|
673
706
|
result. Runtime safety checks and `toolBatchPolicy` remain authoritative.
|
package/dist/index.d.ts
CHANGED
|
@@ -603,6 +603,19 @@ export type AgentOptions<TContext = unknown> = {
|
|
|
603
603
|
* with the same name throws).
|
|
604
604
|
*/
|
|
605
605
|
outputSchema?: OutputSchema;
|
|
606
|
+
/**
|
|
607
|
+
* Whether a validated `submit_output` call ends the run. Only meaningful with
|
|
608
|
+
* `outputSchema`; default `true` — submitting finishes the run immediately
|
|
609
|
+
* with subtype "success", the bounded and cheapest behavior for
|
|
610
|
+
* schema-delivering workers. Set `false` to keep the loop going after a
|
|
611
|
+
* submission (e.g. human-facing sessions that should close with a
|
|
612
|
+
* natural-language summary): the submission is recorded — re-submitting
|
|
613
|
+
* revises it, last one wins — the tool result goes back to the model, and
|
|
614
|
+
* the run ends when the model stops. A text ending after a submission
|
|
615
|
+
* succeeds with the last submission as `SDKResultMessage.structuredResult`;
|
|
616
|
+
* ending without any submission still fails with `error_missing_output`.
|
|
617
|
+
*/
|
|
618
|
+
submitOutputEndTurn?: boolean;
|
|
606
619
|
/** Lifecycle callbacks that rewrite tool results and outgoing model requests. */
|
|
607
620
|
hooks?: AgentHooks<TContext>;
|
|
608
621
|
/**
|
|
@@ -872,6 +885,17 @@ export type AgentToolOptions = {
|
|
|
872
885
|
* runtime the projected prompt must be a string.
|
|
873
886
|
*/
|
|
874
887
|
mapInput?: (input: any) => string | ContentBlock[];
|
|
888
|
+
/**
|
|
889
|
+
* Same contract as `ToolOptions.isConcurrencySafe`: under
|
|
890
|
+
* `toolConcurrency.mode: "safe"` (the default), only calls whose declaration
|
|
891
|
+
* returns true here run in parallel; omitted means sequential. For typed
|
|
892
|
+
* delegation the input is the `inputSchema`-validated value (the same value
|
|
893
|
+
* `mapInput` receives); for default delegation it is the `AgentToolInput`
|
|
894
|
+
* shape. Note the target matters: an AgentSpec spawns a fresh session per
|
|
895
|
+
* call, while an AgentLike target keeps history across calls and is usually
|
|
896
|
+
* not safe to call concurrently.
|
|
897
|
+
*/
|
|
898
|
+
isConcurrencySafe?: (input: any) => boolean;
|
|
875
899
|
};
|
|
876
900
|
/**
|
|
877
901
|
* An AgentLike is a live session: it keeps its conversation history across
|