@xbbg/langgraph 1.4.10 → 1.4.12
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 +38 -15
- package/dist/index.d.ts +24 -1
- package/dist/index.js +1302 -247
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @xbbg/langgraph
|
|
2
2
|
|
|
3
|
+
Last updated: 2026-09-04.
|
|
4
|
+
|
|
3
5
|
LangChain/LangGraph-compatible Bloomberg tools backed by [`@xbbg/core`](../js-xbbg/README.md).
|
|
4
6
|
|
|
5
7
|
This package is a reusable tool adapter. It is not a chat app, HTTP server, MCP server, browser package, or agent framework.
|
|
@@ -119,7 +121,7 @@ const graph = new StateGraph(MessagesAnnotation)
|
|
|
119
121
|
.compile();
|
|
120
122
|
```
|
|
121
123
|
|
|
122
|
-
All tools use LangChain `responseFormat: "content_and_artifact"`. In `ToolNode`, the tool message content
|
|
124
|
+
All tools use LangChain `responseFormat: "content_and_artifact"`. In `ToolNode`, the tool message content is a separately bounded model-facing preview; `artifact` is the structured, independently bounded projection for application code. Content normally starts with a compact summary followed by JSON, but very small byte budgets can reduce it to a compact summary alone.
|
|
123
125
|
|
|
124
126
|
## Tool factories
|
|
125
127
|
|
|
@@ -151,10 +153,11 @@ Core Bloomberg request tools:
|
|
|
151
153
|
|
|
152
154
|
The `xbbg_bdp`, `xbbg_bds`, `xbbg_bdh`, `xbbg_bdib`, and `xbbg_bdtick` inputs accept `returnEids: true`. These map only to Bloomberg's EID-capable `ReferenceDataRequest` (including BDS), `HistoricalDataRequest`, `IntradayBarRequest`, and `IntradayTickRequest` operations.
|
|
153
155
|
|
|
154
|
-
When EIDs are requested, bounded tool artifacts retain result metadata alongside the bounded rows:
|
|
156
|
+
When EIDs are requested, bounded tool artifacts can retain result metadata alongside the bounded rows. For example, an untruncated zero-row artifact can include:
|
|
155
157
|
|
|
156
158
|
```json
|
|
157
159
|
{
|
|
160
|
+
"tool": "xbbg_bdp",
|
|
158
161
|
"data": {
|
|
159
162
|
"rows": [],
|
|
160
163
|
"eidData": { "<TICKER> <MARKET_SECTOR>": [101, 202] },
|
|
@@ -165,7 +168,7 @@ When EIDs are requested, bounded tool artifacts retain result metadata alongside
|
|
|
165
168
|
}
|
|
166
169
|
```
|
|
167
170
|
|
|
168
|
-
|
|
171
|
+
The row limit alone does not discard attached `eidData`, `metadata`, `securityErrors`, or `fieldExceptions`; byte, node, string, and entitlement limits still apply. Diagnostics and EID metadata are prioritized over ordinary properties. When present, `eidDataTruncation` reports retained IDs and securities, omissions, and whether original totals are complete; an unknown original count is not zero. Metadata may itself be omitted under tighter budgets, so inspect the truncation diagnostics before treating an EID map as complete. Pass the collected IDs to `xbbg_check_entitlements`:
|
|
169
172
|
|
|
170
173
|
```json
|
|
171
174
|
{ "eids": [101, 202], "service": "//blp/refdata" }
|
|
@@ -178,6 +181,8 @@ Dealer quote / BQR workflows in xbbg use fixed-income identifiers with a quote s
|
|
|
178
181
|
|
|
179
182
|
Streaming surfaces are intentionally exposed only as bounded snapshot tools. Each snapshot requires `maxUpdates`, applies the configured `maxStreamUpdates`/`maxStreamWaitMs` caps, stops on count, timeout, or stream completion, and calls `unsubscribe(false)` unless `drain: true` is explicitly provided. The package does not expose open-ended async subscription iterators as agent tools. If collection succeeds but releasing the subscription fails, the snapshot result still returns the collected updates and reports the failure in an `unsubscribeError` field instead of discarding data.
|
|
180
183
|
|
|
184
|
+
Arrow snapshot rows share one materialization allowance across all updates, not a fresh allowance for each table: at most `min(max(maxRows, maxContentRows), floor(maxResultNodes / 3))` rows are read before projection. Materialized rows are charged to the same aggregate node budget used for result bounding. An update cut short at this stage carries `rowCount`, `rows`, `truncated`, and a `truncation` diagnostic with `reason: "max_rows"` and `omittedRowsAtLeast`. A collection failure remains the primary thrown error even if unsubscribe also fails.
|
|
185
|
+
|
|
181
186
|
```ts
|
|
182
187
|
import { createBloombergTools, createBdpTool } from "@xbbg/langgraph";
|
|
183
188
|
|
|
@@ -256,14 +261,26 @@ Tools honor the LangChain/LangGraph `AbortSignal` (`graph.invoke(input, { signal
|
|
|
256
261
|
|
|
257
262
|
## Limits and outputs
|
|
258
263
|
|
|
259
|
-
Defaults:
|
|
264
|
+
Numeric options must be positive safe integers. Defaults and minima:
|
|
265
|
+
|
|
266
|
+
| Option | Default | Minimum | Scope |
|
|
267
|
+
| -------------------- | --------: | ------: | --------------------------------------------------------------------------------------------- |
|
|
268
|
+
| `maxSecurities` | 25 | 1 | Securities per request |
|
|
269
|
+
| `maxFields` | 25 | 1 | Fields per request |
|
|
270
|
+
| `maxRows` | 500 | 1 | Aggregate primary rows in the application artifact |
|
|
271
|
+
| `maxResultBytes` | 1,048,576 | 256 | UTF-8 bytes of the serialized artifact, including its envelope |
|
|
272
|
+
| `maxContentRows` | 50 | 1 | Aggregate primary rows in model-facing content |
|
|
273
|
+
| `maxContentBytes` | 65,536 | 256 | UTF-8 bytes of the complete model-facing content, including summary and JSON |
|
|
274
|
+
| `maxResultNodes` | 50,000 | 10 | Aggregate inspection work across materialization, canonical preparation, and both projections |
|
|
275
|
+
| `maxStringChars` | 2,000 | 1 | String bounding before the two projections |
|
|
276
|
+
| `maxBqlQueryChars` | 4,000 | 1 | BQL input length |
|
|
277
|
+
| `maxSearchSpecChars` | 1,000 | 1 | Search specification input length |
|
|
278
|
+
| `maxStreamUpdates` | 10 | 1 | Snapshot updates |
|
|
279
|
+
| `maxStreamWaitMs` | 15,000 | 1 | Snapshot wait in milliseconds |
|
|
260
280
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
- `maxStringChars = 2000`
|
|
265
|
-
- `maxStreamUpdates = 10`
|
|
266
|
-
- `maxStreamWaitMs = 15000`
|
|
281
|
+
Artifact and content limits are independent, not successive cuts of the artifact. A smaller model preview does not shrink the application artifact; conversely, `maxRows: 1` and `maxContentRows: 3` can retain one artifact row and three model rows when the other budgets permit. Both projections come from a shared bounded preparation of the original result, so exhausted shared node or string limits can affect both. These are ceilings, not promises to fill every row or byte allowance.
|
|
282
|
+
|
|
283
|
+
The node budget is aggregate across the whole result, including nested properties and both projections; it does not reset for each object or array. Primary row collections likewise share the relevant projection's row allowance. Depth is capped at 32. Cycles, accessors, binary data, unsupported values, upstream truncation, and exhausted row/string/node/byte budgets produce explicit truncation reasons rather than unbounded traversal or raw binary output.
|
|
267
284
|
|
|
268
285
|
Date inputs accept `YYYY-MM-DD` or `YYYYMMDD` strings, integer `YYYYMMDD` values (parsed as calendar dates), and epoch milliseconds; ambiguous numbers between those ranges and ambiguous `MM/DD/YYYY` strings are rejected with actionable schema errors. `Date` instances are deliberately not part of the wire contract: JSON tool calls cannot carry them and `z.date()` breaks JSON Schema conversion in zod v4.
|
|
269
286
|
|
|
@@ -271,24 +288,30 @@ Schemas only advertise parameters the engine accepts: `format` exists on `xbbg_b
|
|
|
271
288
|
|
|
272
289
|
Empty results are called out in the model-facing summary (`empty result; verify identifiers, fields, and date range before concluding no data exists`) so agents distinguish "no rows" from silent failure instead of inventing data.
|
|
273
290
|
|
|
274
|
-
|
|
291
|
+
Finite request results use `backend: "json"`. For a small untruncated result, model-facing content can look like:
|
|
275
292
|
|
|
276
293
|
```text
|
|
277
|
-
xbbg_bdp: 1 row;
|
|
278
|
-
{"tool":"xbbg_bdp","rowCount":1,"truncated":false,"data":[{"security":"
|
|
294
|
+
xbbg_bdp: 1 row; artifactTruncated=false; contentTruncated=false; artifactReasons=none; contentReasons=none
|
|
295
|
+
{"tool":"xbbg_bdp","rowCount":1,"truncated":false,"contentTruncated":false,"data":[{"security":"AAPL US Equity","field":"PX_LAST","value":190.1}]}
|
|
279
296
|
```
|
|
280
297
|
|
|
281
|
-
The
|
|
298
|
+
The corresponding application artifact has its own envelope and budget:
|
|
282
299
|
|
|
283
300
|
```json
|
|
284
301
|
{
|
|
285
302
|
"tool": "xbbg_bdp",
|
|
286
303
|
"rowCount": 1,
|
|
287
304
|
"truncated": false,
|
|
288
|
-
"data": [{ "security": "
|
|
305
|
+
"data": [{ "security": "AAPL US Equity", "field": "PX_LAST", "value": 190.1 }]
|
|
289
306
|
}
|
|
290
307
|
```
|
|
291
308
|
|
|
309
|
+
These examples illustrate the current shape, not an exhaustive field list. `data` varies by tool and can include a metadata-bearing object with `rows` rather than a bare array. `rowCount` describes the source count when known (or is `null`), not necessarily the number of rows retained. `truncated` in the artifact and normal content payload refers to the artifact; `contentTruncated` and the summary's separate reason lists describe model-preview limits.
|
|
310
|
+
|
|
311
|
+
When available, `truncation` includes `reasons`, `inspectedNodes`, `retainedNodes`, `omittedRows`, and `omittedPropertiesAtLeast`. Lower-bound counts deliberately do not claim an exhaustive scan. Small budgets can omit counters or data while retaining a compact truncation indication. Check diagnostics rather than inferring completeness from a short result.
|
|
312
|
+
|
|
313
|
+
Bloomberg errors are prioritized ahead of ordinary properties, and model content can expose them separately under `diagnostics` even when the relevant data rows are omitted. `hasErrors: true` marks detected errors; tight content budgets use a compact summary to retain that signal. Bounded primary diagnostics are retained in small-budget previews where they fit, rather than replaced by an apparent success or empty result. This does not guarantee every error record or its full text survives every budget. Thrown `Error` instances keep the original error as `cause` and preserve its name when wrapped with tool context; snapshot cleanup failures do not replace a primary collection error.
|
|
314
|
+
|
|
292
315
|
When invoking tools outside an agent graph and you need the artifact, invoke with a tool-call id (or use LangGraph `ToolNode`) so LangChain returns a `ToolMessage` with `artifact`.
|
|
293
316
|
|
|
294
317
|
Use smaller factories or `disabledTools` when broad BQL/search helpers are not appropriate for a deployment.
|
package/dist/index.d.ts
CHANGED
|
@@ -31,8 +31,17 @@ interface BloombergToolsOptions {
|
|
|
31
31
|
readonly core?: XbbgCoreLike;
|
|
32
32
|
readonly maxSecurities?: number;
|
|
33
33
|
readonly maxFields?: number;
|
|
34
|
+
/** Maximum aggregate primary rows retained in the structured artifact. */
|
|
34
35
|
readonly maxRows?: number;
|
|
35
36
|
readonly maxStringChars?: number;
|
|
37
|
+
/** Maximum UTF-8 bytes retained in the structured tool artifact. Minimum 256. */
|
|
38
|
+
readonly maxResultBytes?: number;
|
|
39
|
+
/** Maximum aggregate values/properties inspected while bounding one result. Minimum 10. */
|
|
40
|
+
readonly maxResultNodes?: number;
|
|
41
|
+
/** Maximum UTF-8 bytes sent back to the model as tool content. Minimum 256. */
|
|
42
|
+
readonly maxContentBytes?: number;
|
|
43
|
+
/** Maximum aggregate primary rows in model content; independent of artifact maxRows. */
|
|
44
|
+
readonly maxContentRows?: number;
|
|
36
45
|
readonly maxBqlQueryChars?: number;
|
|
37
46
|
readonly maxSearchSpecChars?: number;
|
|
38
47
|
readonly maxStreamUpdates?: number;
|
|
@@ -48,6 +57,10 @@ interface NormalizedBloombergToolsOptions {
|
|
|
48
57
|
readonly maxFields: number;
|
|
49
58
|
readonly maxRows: number;
|
|
50
59
|
readonly maxStringChars: number;
|
|
60
|
+
readonly maxResultBytes: number;
|
|
61
|
+
readonly maxResultNodes: number;
|
|
62
|
+
readonly maxContentBytes: number;
|
|
63
|
+
readonly maxContentRows: number;
|
|
51
64
|
readonly maxBqlQueryChars: number;
|
|
52
65
|
readonly maxSearchSpecChars: number;
|
|
53
66
|
readonly maxStreamUpdates: number;
|
|
@@ -108,10 +121,20 @@ declare function createExtCalculateTool(options?: BloombergToolsOptions): Bloomb
|
|
|
108
121
|
declare function createExtChartSpecTool(options?: BloombergToolsOptions): BloombergTool;
|
|
109
122
|
declare function createBloombergExtTools(options?: BloombergToolsOptions): BloombergTool[];
|
|
110
123
|
|
|
124
|
+
type ResultTruncationReason = "accessor_omitted" | "binary_data" | "circular_reference" | "entitlement_limit" | "invalid_entitlement_data" | "max_result_bytes" | "max_result_depth" | "max_result_nodes" | "max_rows" | "max_string_chars" | "unsupported_value" | "upstream_truncation";
|
|
125
|
+
interface ResultTruncationSummary {
|
|
126
|
+
readonly reasons: readonly ResultTruncationReason[];
|
|
127
|
+
readonly retainedNodes?: number;
|
|
128
|
+
readonly inspectedNodes?: number;
|
|
129
|
+
readonly omittedPropertiesAtLeast?: number;
|
|
130
|
+
readonly omittedRows?: number;
|
|
131
|
+
}
|
|
111
132
|
interface ToolEnvelope {
|
|
112
133
|
readonly tool: BloombergToolName;
|
|
113
134
|
readonly rowCount: number | null;
|
|
114
135
|
readonly truncated: boolean;
|
|
136
|
+
readonly truncation?: ResultTruncationSummary;
|
|
137
|
+
readonly hasErrors?: true;
|
|
115
138
|
readonly data: unknown;
|
|
116
139
|
}
|
|
117
140
|
|
|
@@ -195,4 +218,4 @@ interface ChartSpecOutput {
|
|
|
195
218
|
|
|
196
219
|
declare function createAllBloombergTools(options?: BloombergToolsOptions): BloombergTool[];
|
|
197
220
|
|
|
198
|
-
export { BLOOMBERG_EXT_TOOL_NAMES, BLOOMBERG_TOOL_INSTRUCTIONS, BLOOMBERG_TOOL_NAMES, type BloombergChartSource, type BloombergTool, type BloombergToolInstructionsOptions, type BloombergToolName, type BloombergToolsOptions, type ChartKind, type ChartRenderer, type ChartRow, type ChartScalar, type ChartSpecInput, type ChartSpecOutput, type ChartSpecSummary, DEFAULT_ENGINE_REQUEST_TIMEOUT_MS, type NormalizedBloombergToolsOptions, type ToolEnvelope, type ToolInvocationConfig, type VegaLiteSpec, createAllBloombergTools, createBdhTool, createBdibTool, createBdpTool, createBdsTool, createBdtickTool, createBeqsTool, createBfldsTool, createBloombergExtTools, createBloombergTools, createBqlTool, createBqrTool, createBsrchTool, createCheckEntitlementsTool, createCorporateBondsTool, createDepthSnapshotTool, createEtfHoldingsTool, createExtBqlBuilderTool, createExtCalculateTool, createExtCdxTool, createExtChartSpecTool, createExtColumnsTool, createExtConstantsTool, createExtCurrencyTool, createExtFuturesTool, createExtMarketSessionTool, createExtTickerTool, createExtYasOverridesTool, createIndexMembersTool, createIssuerIsinsTool, createMktbarSnapshotTool, createPreferredsTool, createResolveIsinsTool, createStreamSnapshotTool, createYasTool, getBloombergToolInstructions, toolParameterJsonSchema };
|
|
221
|
+
export { BLOOMBERG_EXT_TOOL_NAMES, BLOOMBERG_TOOL_INSTRUCTIONS, BLOOMBERG_TOOL_NAMES, type BloombergChartSource, type BloombergTool, type BloombergToolInstructionsOptions, type BloombergToolName, type BloombergToolsOptions, type ChartKind, type ChartRenderer, type ChartRow, type ChartScalar, type ChartSpecInput, type ChartSpecOutput, type ChartSpecSummary, DEFAULT_ENGINE_REQUEST_TIMEOUT_MS, type NormalizedBloombergToolsOptions, type ResultTruncationReason, type ResultTruncationSummary, type ToolEnvelope, type ToolInvocationConfig, type VegaLiteSpec, createAllBloombergTools, createBdhTool, createBdibTool, createBdpTool, createBdsTool, createBdtickTool, createBeqsTool, createBfldsTool, createBloombergExtTools, createBloombergTools, createBqlTool, createBqrTool, createBsrchTool, createCheckEntitlementsTool, createCorporateBondsTool, createDepthSnapshotTool, createEtfHoldingsTool, createExtBqlBuilderTool, createExtCalculateTool, createExtCdxTool, createExtChartSpecTool, createExtColumnsTool, createExtConstantsTool, createExtCurrencyTool, createExtFuturesTool, createExtMarketSessionTool, createExtTickerTool, createExtYasOverridesTool, createIndexMembersTool, createIssuerIsinsTool, createMktbarSnapshotTool, createPreferredsTool, createResolveIsinsTool, createStreamSnapshotTool, createYasTool, getBloombergToolInstructions, toolParameterJsonSchema };
|