agent-lattice 0.23.0 → 0.24.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 +26 -2
- package/dist/index.d.ts +11 -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
|
|
|
@@ -668,6 +684,14 @@ an `isConcurrencySafe` declaration stay sequential. Use `mode: "all"` only when
|
|
|
668
684
|
every tool in the Agent is safe to overlap. Use `mode: "sequential"` to disable
|
|
669
685
|
tool concurrency even for tools marked safe.
|
|
670
686
|
|
|
687
|
+
`agentTool()` accepts the same declaration as `AgentToolOptions.isConcurrencySafe`,
|
|
688
|
+
so a supervisor can fan out independent delegations in one turn. The input the
|
|
689
|
+
predicate receives is the tool's parsed input — the `inputSchema`-validated
|
|
690
|
+
value for typed delegation, the `AgentToolInput` shape otherwise. Keep in mind
|
|
691
|
+
the target's lifecycle: an `AgentSpec` spawns a fresh session per call, while an
|
|
692
|
+
`AgentLike` target keeps history across calls and is usually not safe to call
|
|
693
|
+
concurrently. *Requires 0.24.0 or later.*
|
|
694
|
+
|
|
671
695
|
When concurrency is available, the SDK tells the model to batch independent
|
|
672
696
|
calls and to use separate assistant responses when a later call needs an earlier
|
|
673
697
|
result. Runtime safety checks and `toolBatchPolicy` remain authoritative.
|
package/dist/index.d.ts
CHANGED
|
@@ -872,6 +872,17 @@ export type AgentToolOptions = {
|
|
|
872
872
|
* runtime the projected prompt must be a string.
|
|
873
873
|
*/
|
|
874
874
|
mapInput?: (input: any) => string | ContentBlock[];
|
|
875
|
+
/**
|
|
876
|
+
* Same contract as `ToolOptions.isConcurrencySafe`: under
|
|
877
|
+
* `toolConcurrency.mode: "safe"` (the default), only calls whose declaration
|
|
878
|
+
* returns true here run in parallel; omitted means sequential. For typed
|
|
879
|
+
* delegation the input is the `inputSchema`-validated value (the same value
|
|
880
|
+
* `mapInput` receives); for default delegation it is the `AgentToolInput`
|
|
881
|
+
* shape. Note the target matters: an AgentSpec spawns a fresh session per
|
|
882
|
+
* call, while an AgentLike target keeps history across calls and is usually
|
|
883
|
+
* not safe to call concurrently.
|
|
884
|
+
*/
|
|
885
|
+
isConcurrencySafe?: (input: any) => boolean;
|
|
875
886
|
};
|
|
876
887
|
/**
|
|
877
888
|
* An AgentLike is a live session: it keeps its conversation history across
|