@struct-ai/sdk 0.4.2 → 0.4.3

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
@@ -293,6 +293,28 @@ Emits attributes per the OTel GenAI semantic conventions:
293
293
  - `gen_ai.tool.{name, call.id, call.arguments, call.result}`
294
294
  - `error.type` + `StatusCode.ERROR` on failures
295
295
 
296
+ ### `error.type` values emitted
297
+
298
+ The OTel conventions ask instrumentations to document the error values they
299
+ report ("Instrumentations SHOULD document the list of errors they report").
300
+ This SDK emits exactly two kinds of value, both alongside span
301
+ `StatusCode.ERROR`:
302
+
303
+ | Value | When | Meaning |
304
+ | --- | --- | --- |
305
+ | exception class name (e.g. `TypeError`, `APIConnectionError`) | the instrumented call threw | We failed to execute the request. Also records an OTel exception event. |
306
+ | `tool_error` | an `execute_tool` span whose result signalled failure **in band** — Anthropic `tool_result` blocks with `is_error: true`, MCP `CallToolResult.isError`, or a LangChain `ToolMessage` with `status: "error"` | The tool ran and reported a failure back to the model (bad arguments, a domain "no"), so the model can self-correct. No exception object exists, so no class name is available. |
307
+
308
+ `tool_error` is a deliberate low-cardinality sentinel, which the `error.type`
309
+ convention explicitly permits ("another low-cardinality error identifier"; a
310
+ custom value MAY be used where no well-known one applies). The same split is
311
+ used by OpenTelemetry's MCP instrumentation in OpenLLMetry, which likewise
312
+ reports `error.type="tool_error"` for the `isError` path and the exception
313
+ class name otherwise. Matches the Python SDK.
314
+
315
+ The distinction is what lets a monitor page on genuine execution failures
316
+ while excluding failures the model already saw and can recover from.
317
+
296
318
  Note: `gen_ai.usage.input_tokens` for Anthropic is the TRUE total — we add back
297
319
  `cache_read_input_tokens + cache_creation_input_tokens` (which Anthropic's raw
298
320
  response excludes). Matches the Python SDK.
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "0.4.2";
1
+ export declare const SDK_VERSION = "0.4.3";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
4
  // Keep in sync with package.json; test/version.test.ts enforces it.
5
- exports.SDK_VERSION = "0.4.2";
5
+ exports.SDK_VERSION = "0.4.3";
6
6
  //# sourceMappingURL=version.js.map
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "0.4.2";
1
+ export declare const SDK_VERSION = "0.4.3";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with package.json; test/version.test.ts enforces it.
2
- export const SDK_VERSION = "0.4.2";
2
+ export const SDK_VERSION = "0.4.3";
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@struct-ai/sdk",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Struct agent observability SDK — auto-instruments AI agent frameworks with OpenTelemetry",
5
5
  "type": "module",
6
6
  "main": "./dist/commonjs/index.js",