langsmith 0.5.18 → 0.5.19

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/dist/client.cjs CHANGED
@@ -679,6 +679,24 @@ class Client {
679
679
  }
680
680
  return outputs;
681
681
  }
682
+ /**
683
+ * Filter content from new_token events to prevent streaming LLM output
684
+ * from being uploaded via events.
685
+ */
686
+ _filterNewTokenEvents(events) {
687
+ if (!events || events.length === 0) {
688
+ return events;
689
+ }
690
+ return events.map((event) => {
691
+ if (event.name === "new_token") {
692
+ // Remove the kwargs containing the token data
693
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
694
+ const { kwargs: _, ...rest } = event;
695
+ return rest;
696
+ }
697
+ return event;
698
+ });
699
+ }
682
700
  async prepareRunCreateOrUpdateInputs(run) {
683
701
  const runParams = { ...run };
684
702
  if (runParams.inputs !== undefined) {
@@ -687,6 +705,9 @@ class Client {
687
705
  if (runParams.outputs !== undefined) {
688
706
  runParams.outputs = await this.processOutputs(runParams.outputs);
689
707
  }
708
+ if (runParams.events !== undefined) {
709
+ runParams.events = this._filterNewTokenEvents(runParams.events);
710
+ }
690
711
  return runParams;
691
712
  }
692
713
  async _getResponse(path, queryParams) {
@@ -1531,6 +1552,9 @@ class Client {
1531
1552
  if (run.outputs) {
1532
1553
  run.outputs = await this.processOutputs(run.outputs);
1533
1554
  }
1555
+ if (run.events) {
1556
+ run.events = this._filterNewTokenEvents(run.events);
1557
+ }
1534
1558
  // TODO: Untangle types
1535
1559
  const data = { ...run, id: runId };
1536
1560
  if (!this._filterForSampling([data], true).length) {
package/dist/client.d.ts CHANGED
@@ -445,6 +445,11 @@ export declare class Client implements LangSmithTracingClientInterface {
445
445
  private _getPlatformEndpointPath;
446
446
  private processInputs;
447
447
  private processOutputs;
448
+ /**
449
+ * Filter content from new_token events to prevent streaming LLM output
450
+ * from being uploaded via events.
451
+ */
452
+ private _filterNewTokenEvents;
448
453
  private prepareRunCreateOrUpdateInputs;
449
454
  private _getResponse;
450
455
  private _get;
package/dist/client.js CHANGED
@@ -641,6 +641,24 @@ export class Client {
641
641
  }
642
642
  return outputs;
643
643
  }
644
+ /**
645
+ * Filter content from new_token events to prevent streaming LLM output
646
+ * from being uploaded via events.
647
+ */
648
+ _filterNewTokenEvents(events) {
649
+ if (!events || events.length === 0) {
650
+ return events;
651
+ }
652
+ return events.map((event) => {
653
+ if (event.name === "new_token") {
654
+ // Remove the kwargs containing the token data
655
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
656
+ const { kwargs: _, ...rest } = event;
657
+ return rest;
658
+ }
659
+ return event;
660
+ });
661
+ }
644
662
  async prepareRunCreateOrUpdateInputs(run) {
645
663
  const runParams = { ...run };
646
664
  if (runParams.inputs !== undefined) {
@@ -649,6 +667,9 @@ export class Client {
649
667
  if (runParams.outputs !== undefined) {
650
668
  runParams.outputs = await this.processOutputs(runParams.outputs);
651
669
  }
670
+ if (runParams.events !== undefined) {
671
+ runParams.events = this._filterNewTokenEvents(runParams.events);
672
+ }
652
673
  return runParams;
653
674
  }
654
675
  async _getResponse(path, queryParams) {
@@ -1493,6 +1514,9 @@ export class Client {
1493
1514
  if (run.outputs) {
1494
1515
  run.outputs = await this.processOutputs(run.outputs);
1495
1516
  }
1517
+ if (run.events) {
1518
+ run.events = this._filterNewTokenEvents(run.events);
1519
+ }
1496
1520
  // TODO: Untangle types
1497
1521
  const data = { ...run, id: runId };
1498
1522
  if (!this._filterForSampling([data], true).length) {
@@ -133,6 +133,11 @@ class StreamManager {
133
133
  run_type: "chain",
134
134
  inputs: block.input,
135
135
  start_time: eventTime,
136
+ extra: {
137
+ metadata: {
138
+ ls_agent_type: "subagent",
139
+ },
140
+ },
136
141
  }) ?? this.tools[block.id];
137
142
  this.namespaces[block.id] ??= this.tools[block.id];
138
143
  }
@@ -130,6 +130,11 @@ export class StreamManager {
130
130
  run_type: "chain",
131
131
  inputs: block.input,
132
132
  start_time: eventTime,
133
+ extra: {
134
+ metadata: {
135
+ ls_agent_type: "subagent",
136
+ },
137
+ },
133
138
  }) ?? this.tools[block.id];
134
139
  this.namespaces[block.id] ??= this.tools[block.id];
135
140
  }
@@ -112,6 +112,7 @@ function wrapClaudeAgentQuery(queryFn, defaultThis, baseConfig) {
112
112
  ...baseConfig,
113
113
  metadata: {
114
114
  ls_integration: "claude-agent-sdk-js",
115
+ ls_agent_type: "root",
115
116
  ...baseConfig?.metadata,
116
117
  },
117
118
  __deferredSerializableArgOptions: { maxDepth: 1 },
@@ -109,6 +109,7 @@ function wrapClaudeAgentQuery(queryFn, defaultThis, baseConfig) {
109
109
  ...baseConfig,
110
110
  metadata: {
111
111
  ls_integration: "claude-agent-sdk-js",
112
+ ls_agent_type: "root",
112
113
  ...baseConfig?.metadata,
113
114
  },
114
115
  __deferredSerializableArgOptions: { maxDepth: 1 },
@@ -53,6 +53,8 @@ function getDefaultApiKey() {
53
53
  * await sandbox.delete();
54
54
  * }
55
55
  * ```
56
+ *
57
+ * @experimental This feature is experimental, and breaking changes are expected.
56
58
  */
57
59
  class SandboxClient {
58
60
  constructor(config = {}) {
@@ -30,6 +30,8 @@ import { Sandbox } from "./sandbox.js";
30
30
  * await sandbox.delete();
31
31
  * }
32
32
  * ```
33
+ *
34
+ * @experimental This feature is experimental, and breaking changes are expected.
33
35
  */
34
36
  export declare class SandboxClient {
35
37
  private _baseUrl;
@@ -50,6 +50,8 @@ function getDefaultApiKey() {
50
50
  * await sandbox.delete();
51
51
  * }
52
52
  * ```
53
+ *
54
+ * @experimental This feature is experimental, and breaking changes are expected.
53
55
  */
54
56
  export class SandboxClient {
55
57
  constructor(config = {}) {
@@ -25,9 +25,6 @@
25
25
  */
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.LangSmithDataplaneNotConfiguredError = exports.LangSmithCommandTimeoutError = exports.LangSmithSandboxOperationError = exports.LangSmithSandboxNotReadyError = exports.LangSmithSandboxCreationError = exports.LangSmithResourceCreationError = exports.LangSmithQuotaExceededError = exports.LangSmithValidationError = exports.LangSmithResourceNameConflictError = exports.LangSmithResourceAlreadyExistsError = exports.LangSmithResourceInUseError = exports.LangSmithResourceTimeoutError = exports.LangSmithResourceNotFoundError = exports.LangSmithSandboxServerReloadError = exports.LangSmithSandboxConnectionError = exports.LangSmithSandboxAuthenticationError = exports.LangSmithSandboxAPIError = exports.LangSmithSandboxError = exports.CommandHandle = exports.Sandbox = exports.SandboxClient = void 0;
28
- // Emit warning on import (alpha feature)
29
- console.warn("langsmith/experimental/sandbox is in alpha. " +
30
- "This feature is experimental, and breaking changes are expected.");
31
28
  // Main classes
32
29
  var client_js_1 = require("./client.cjs");
33
30
  Object.defineProperty(exports, "SandboxClient", { enumerable: true, get: function () { return client_js_1.SandboxClient; } });
@@ -22,9 +22,6 @@
22
22
  *
23
23
  * @packageDocumentation
24
24
  */
25
- // Emit warning on import (alpha feature)
26
- console.warn("langsmith/experimental/sandbox is in alpha. " +
27
- "This feature is experimental, and breaking changes are expected.");
28
25
  // Main classes
29
26
  export { SandboxClient } from "./client.js";
30
27
  export { Sandbox } from "./sandbox.js";
@@ -25,6 +25,8 @@ const ws_execute_js_1 = require("./ws_execute.cjs");
25
25
  * await sandbox.delete();
26
26
  * }
27
27
  * ```
28
+ *
29
+ * @experimental This feature is experimental, and breaking changes are expected.
28
30
  */
29
31
  class Sandbox {
30
32
  /** @internal */
@@ -20,6 +20,8 @@ import { CommandHandle } from "./command_handle.js";
20
20
  * await sandbox.delete();
21
21
  * }
22
22
  * ```
23
+ *
24
+ * @experimental This feature is experimental, and breaking changes are expected.
23
25
  */
24
26
  export declare class Sandbox {
25
27
  /** Display name (can be updated). */
@@ -22,6 +22,8 @@ import { reconnectWsStream, runWsStream } from "./ws_execute.js";
22
22
  * await sandbox.delete();
23
23
  * }
24
24
  * ```
25
+ *
26
+ * @experimental This feature is experimental, and breaking changes are expected.
25
27
  */
26
28
  export class Sandbox {
27
29
  /** @internal */
@@ -118,11 +118,19 @@ const _resolveConfigs = (baseLsConfig, runtimeLsConfig) => {
118
118
  resolvedToolConfig,
119
119
  };
120
120
  };
121
+ const _getLsAgentType = () => {
122
+ const parentRun = (0, traceable_js_1.getCurrentRunTree)(true);
123
+ if (parentRun != null && parentRun.run_type === "tool") {
124
+ return "subagent";
125
+ }
126
+ return "root";
127
+ };
121
128
  const _getGenerateTextWrapperConfig = ({ model, runName, aiSdkMethodName, resolvedLsConfig, hasExplicitOutput, hasExplicitExperimentalOutput, traceResponseMetadata, }) => {
122
129
  return {
123
130
  name: runName ?? _getModelDisplayName(model),
124
131
  ...resolvedLsConfig,
125
132
  metadata: {
133
+ ls_agent_type: _getLsAgentType(),
126
134
  ai_sdk_method: aiSdkMethodName ?? "ai.generateText",
127
135
  ...resolvedLsConfig?.metadata,
128
136
  },
@@ -198,6 +206,7 @@ const _getStreamTextWrapperConfig = ({ model, runName, aiSdkMethodName, resolved
198
206
  name: runName ?? _getModelDisplayName(model),
199
207
  ...resolvedLsConfig,
200
208
  metadata: {
209
+ ls_agent_type: _getLsAgentType(),
201
210
  ai_sdk_method: aiSdkMethodName ?? "ai.streamText",
202
211
  ...resolvedLsConfig?.metadata,
203
212
  },
@@ -400,6 +409,7 @@ const wrapAISDK = (ai, baseLsConfig) => {
400
409
  name: _getModelDisplayName(params.model),
401
410
  ...resolvedLsConfig,
402
411
  metadata: {
412
+ ls_agent_type: _getLsAgentType(),
403
413
  ai_sdk_method: "ai.generateObject",
404
414
  ...resolvedLsConfig?.metadata,
405
415
  },
@@ -521,6 +531,7 @@ const wrapAISDK = (ai, baseLsConfig) => {
521
531
  name: _getModelDisplayName(params.model),
522
532
  ...resolvedLsConfig,
523
533
  metadata: {
534
+ ls_agent_type: _getLsAgentType(),
524
535
  ai_sdk_method: "ai.streamObject",
525
536
  ...resolvedLsConfig?.metadata,
526
537
  },
@@ -1,6 +1,6 @@
1
1
  import { LangSmithMiddleware, } from "./middleware.js";
2
2
  import { convertMessageToTracedFormat } from "./utils.js";
3
- import { isTraceableFunction, traceable } from "../../traceable.js";
3
+ import { isTraceableFunction, traceable, getCurrentRunTree, } from "../../traceable.js";
4
4
  const _wrapTools = (tools, lsConfig) => {
5
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
6
  const wrappedTools = {};
@@ -114,11 +114,19 @@ const _resolveConfigs = (baseLsConfig, runtimeLsConfig) => {
114
114
  resolvedToolConfig,
115
115
  };
116
116
  };
117
+ const _getLsAgentType = () => {
118
+ const parentRun = getCurrentRunTree(true);
119
+ if (parentRun != null && parentRun.run_type === "tool") {
120
+ return "subagent";
121
+ }
122
+ return "root";
123
+ };
117
124
  const _getGenerateTextWrapperConfig = ({ model, runName, aiSdkMethodName, resolvedLsConfig, hasExplicitOutput, hasExplicitExperimentalOutput, traceResponseMetadata, }) => {
118
125
  return {
119
126
  name: runName ?? _getModelDisplayName(model),
120
127
  ...resolvedLsConfig,
121
128
  metadata: {
129
+ ls_agent_type: _getLsAgentType(),
122
130
  ai_sdk_method: aiSdkMethodName ?? "ai.generateText",
123
131
  ...resolvedLsConfig?.metadata,
124
132
  },
@@ -194,6 +202,7 @@ const _getStreamTextWrapperConfig = ({ model, runName, aiSdkMethodName, resolved
194
202
  name: runName ?? _getModelDisplayName(model),
195
203
  ...resolvedLsConfig,
196
204
  metadata: {
205
+ ls_agent_type: _getLsAgentType(),
197
206
  ai_sdk_method: aiSdkMethodName ?? "ai.streamText",
198
207
  ...resolvedLsConfig?.metadata,
199
208
  },
@@ -395,6 +404,7 @@ const wrapAISDK = (ai, baseLsConfig) => {
395
404
  name: _getModelDisplayName(params.model),
396
405
  ...resolvedLsConfig,
397
406
  metadata: {
407
+ ls_agent_type: _getLsAgentType(),
398
408
  ai_sdk_method: "ai.generateObject",
399
409
  ...resolvedLsConfig?.metadata,
400
410
  },
@@ -516,6 +526,7 @@ const wrapAISDK = (ai, baseLsConfig) => {
516
526
  name: _getModelDisplayName(params.model),
517
527
  ...resolvedLsConfig,
518
528
  metadata: {
529
+ ls_agent_type: _getLsAgentType(),
519
530
  ai_sdk_method: "ai.streamObject",
520
531
  ...resolvedLsConfig?.metadata,
521
532
  },
package/dist/index.cjs CHANGED
@@ -18,4 +18,4 @@ Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function
18
18
  Object.defineProperty(exports, "configureGlobalPromptCache", { enumerable: true, get: function () { return index_js_1.configureGlobalPromptCache; } });
19
19
  Object.defineProperty(exports, "promptCacheSingleton", { enumerable: true, get: function () { return index_js_1.promptCacheSingleton; } });
20
20
  // Update using pnpm bump-version
21
- exports.__version__ = "0.5.18";
21
+ exports.__version__ = "0.5.19";
package/dist/index.d.ts CHANGED
@@ -5,4 +5,4 @@ export { overrideFetchImplementation } from "./singletons/fetch.js";
5
5
  export { getDefaultProjectName } from "./utils/project.js";
6
6
  export { uuid7, uuid7FromTime } from "./uuid.js";
7
7
  export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
8
- export declare const __version__ = "0.5.18";
8
+ export declare const __version__ = "0.5.19";
package/dist/index.js CHANGED
@@ -5,4 +5,4 @@ export { getDefaultProjectName } from "./utils/project.js";
5
5
  export { uuid7, uuid7FromTime } from "./uuid.js";
6
6
  export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
7
7
  // Update using pnpm bump-version
8
- export const __version__ = "0.5.18";
8
+ export const __version__ = "0.5.19";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.5.18",
3
+ "version": "0.5.19",
4
4
  "description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
5
5
  "packageManager": "pnpm@10.33.0",
6
6
  "files": [
@@ -153,7 +153,7 @@
153
153
  "@ai-sdk/openai": "^3.0.0",
154
154
  "@ai-sdk/provider": "^3.0.0",
155
155
  "@anthropic-ai/claude-agent-sdk": "^0.2.83",
156
- "@anthropic-ai/sdk": "^0.82.0",
156
+ "@anthropic-ai/sdk": "^0.88.0",
157
157
  "@babel/preset-env": "^7.22.4",
158
158
  "@faker-js/faker": "^8.4.1",
159
159
  "@google/genai": "^1.29.0",