langsmith 0.10.1 → 0.10.2

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/index.cjs CHANGED
@@ -35,6 +35,6 @@ Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, g
35
35
  Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return error_js_1.RateLimitError; } });
36
36
  Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return error_js_1.InternalServerError; } });
37
37
  // Update using pnpm bump-version
38
- exports.__version__ = "0.10.1";
38
+ exports.__version__ = "0.10.2";
39
39
  // Metadata key to hide a traced run from LangSmith's Messages View.
40
40
  exports.LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
package/dist/index.d.ts CHANGED
@@ -7,5 +7,5 @@ export { computeRunIdForSecondaryReplica, uuid7, uuid7FromTime, } from "./uuid.j
7
7
  export { isTracingEnabled } from "./utils/guard.js";
8
8
  export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
9
9
  export { LangsmithError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_openapi_client/core/error.js";
10
- export declare const __version__ = "0.10.1";
10
+ export declare const __version__ = "0.10.2";
11
11
  export declare const LS_MESSAGE_VIEW_EXCLUDE: "ls_message_view_exclude";
package/dist/index.js CHANGED
@@ -7,6 +7,6 @@ export { isTracingEnabled } from "./utils/guard.js";
7
7
  export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
8
8
  export { LangsmithError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_openapi_client/core/error.js";
9
9
  // Update using pnpm bump-version
10
- export const __version__ = "0.10.1";
10
+ export const __version__ = "0.10.2";
11
11
  // Metadata key to hide a traced run from LangSmith's Messages View.
12
12
  export const LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
@@ -60,9 +60,16 @@ exports.LangSmithSandboxConnectionError = LangSmithSandboxConnectionError;
60
60
  * deduplicate an attempt whose outcome is unknown.
61
61
  */
62
62
  class LangSmithSandboxRetryableConnectionError extends LangSmithSandboxConnectionError {
63
- constructor(message) {
63
+ constructor(message, retryAfterSeconds) {
64
64
  super(message);
65
+ Object.defineProperty(this, "retryAfterSeconds", {
66
+ enumerable: true,
67
+ configurable: true,
68
+ writable: true,
69
+ value: void 0
70
+ });
65
71
  this.name = "LangSmithSandboxRetryableConnectionError";
72
+ this.retryAfterSeconds = retryAfterSeconds;
66
73
  }
67
74
  }
68
75
  exports.LangSmithSandboxRetryableConnectionError = LangSmithSandboxRetryableConnectionError;
@@ -38,7 +38,8 @@ export declare class LangSmithSandboxConnectionError extends LangSmithSandboxErr
38
38
  * deduplicate an attempt whose outcome is unknown.
39
39
  */
40
40
  export declare class LangSmithSandboxRetryableConnectionError extends LangSmithSandboxConnectionError {
41
- constructor(message: string);
41
+ readonly retryAfterSeconds?: number;
42
+ constructor(message: string, retryAfterSeconds?: number);
42
43
  }
43
44
  /**
44
45
  * Raised when a resource is not found.
@@ -53,9 +53,16 @@ export class LangSmithSandboxConnectionError extends LangSmithSandboxError {
53
53
  * deduplicate an attempt whose outcome is unknown.
54
54
  */
55
55
  export class LangSmithSandboxRetryableConnectionError extends LangSmithSandboxConnectionError {
56
- constructor(message) {
56
+ constructor(message, retryAfterSeconds) {
57
57
  super(message);
58
+ Object.defineProperty(this, "retryAfterSeconds", {
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true,
62
+ value: void 0
63
+ });
58
64
  this.name = "LangSmithSandboxRetryableConnectionError";
65
+ this.retryAfterSeconds = retryAfterSeconds;
59
66
  }
60
67
  }
61
68
  // =============================================================================
@@ -272,6 +272,9 @@ class Sandbox {
272
272
  throw e;
273
273
  }
274
274
  let delay = Math.min(command_handle_js_1.CommandHandle.BACKOFF_BASE * 2 ** (attempt - 1), command_handle_js_1.CommandHandle.BACKOFF_MAX);
275
+ if (e instanceof errors_js_1.LangSmithSandboxRetryableConnectionError) {
276
+ delay = e.retryAfterSeconds ?? delay * (0.8 + Math.random() * 0.2);
277
+ }
275
278
  const remaining = (0, ws_execute_js_1.remainingBudget)(deadline);
276
279
  if (remaining !== undefined) {
277
280
  if (remaining <= 0) {
@@ -269,6 +269,9 @@ export class Sandbox {
269
269
  throw e;
270
270
  }
271
271
  let delay = Math.min(CommandHandle.BACKOFF_BASE * 2 ** (attempt - 1), CommandHandle.BACKOFF_MAX);
272
+ if (e instanceof LangSmithSandboxRetryableConnectionError) {
273
+ delay = e.retryAfterSeconds ?? delay * (0.8 + Math.random() * 0.2);
274
+ }
272
275
  const remaining = remainingBudget(deadline);
273
276
  if (remaining !== undefined) {
274
277
  if (remaining <= 0) {
@@ -35,7 +35,14 @@ exports.WS_OPEN_TIMEOUT = envTimeout("SANDBOX_WS_TIMEOUT_OPEN", 30);
35
35
  // Ceiling on the whole connect phase. Without it, retrying a blackholed
36
36
  // handshake costs MAX_AUTO_RECONNECTS + 1 full open timeouts plus backoff.
37
37
  exports.WS_CONNECT_BUDGET = envTimeout("SANDBOX_WS_TIMEOUT_CONNECT_BUDGET", 120);
38
- const RETRYABLE_HANDSHAKE_STATUS_CODES = new Set([500, 502, 503, 504]);
38
+ const RETRYABLE_HANDSHAKE_STATUS_CODES = new Set([429, 500, 502, 503, 504]);
39
+ function retryAfterSeconds(headers) {
40
+ const raw = headers?.["retry-after"];
41
+ if (typeof raw !== "string" || raw.trim() === "")
42
+ return undefined;
43
+ const value = Number(raw);
44
+ return Number.isFinite(value) && value >= 0 ? value : undefined;
45
+ }
39
46
  function nowSeconds() {
40
47
  return performance.now() / 1000;
41
48
  }
@@ -211,10 +218,13 @@ async function connectWs(url, headers, openTimeout = exports.WS_OPEN_TIMEOUT) {
211
218
  if (settled)
212
219
  return;
213
220
  settled = true;
214
- const ErrorType = RETRYABLE_HANDSHAKE_STATUS_CODES.has(res.statusCode ?? 0)
215
- ? errors_js_1.LangSmithSandboxRetryableConnectionError
216
- : errors_js_1.LangSmithSandboxConnectionError;
217
- reject(new ErrorType(`WebSocket upgrade to ${url} rejected by server (HTTP ${res.statusCode})`));
221
+ const message = `WebSocket upgrade to ${url} rejected by server (HTTP ${res.statusCode})`;
222
+ if (RETRYABLE_HANDSHAKE_STATUS_CODES.has(res.statusCode ?? 0)) {
223
+ reject(new errors_js_1.LangSmithSandboxRetryableConnectionError(message, retryAfterSeconds(res.headers)));
224
+ }
225
+ else {
226
+ reject(new errors_js_1.LangSmithSandboxConnectionError(message));
227
+ }
218
228
  });
219
229
  // Stays attached after settling so a late error has a listener and cannot
220
230
  // become an unhandled 'error' event.
@@ -23,7 +23,14 @@ export const WS_OPEN_TIMEOUT = envTimeout("SANDBOX_WS_TIMEOUT_OPEN", 30);
23
23
  // Ceiling on the whole connect phase. Without it, retrying a blackholed
24
24
  // handshake costs MAX_AUTO_RECONNECTS + 1 full open timeouts plus backoff.
25
25
  export const WS_CONNECT_BUDGET = envTimeout("SANDBOX_WS_TIMEOUT_CONNECT_BUDGET", 120);
26
- const RETRYABLE_HANDSHAKE_STATUS_CODES = new Set([500, 502, 503, 504]);
26
+ const RETRYABLE_HANDSHAKE_STATUS_CODES = new Set([429, 500, 502, 503, 504]);
27
+ function retryAfterSeconds(headers) {
28
+ const raw = headers?.["retry-after"];
29
+ if (typeof raw !== "string" || raw.trim() === "")
30
+ return undefined;
31
+ const value = Number(raw);
32
+ return Number.isFinite(value) && value >= 0 ? value : undefined;
33
+ }
27
34
  function nowSeconds() {
28
35
  return performance.now() / 1000;
29
36
  }
@@ -198,10 +205,13 @@ async function connectWs(url, headers, openTimeout = WS_OPEN_TIMEOUT) {
198
205
  if (settled)
199
206
  return;
200
207
  settled = true;
201
- const ErrorType = RETRYABLE_HANDSHAKE_STATUS_CODES.has(res.statusCode ?? 0)
202
- ? LangSmithSandboxRetryableConnectionError
203
- : LangSmithSandboxConnectionError;
204
- reject(new ErrorType(`WebSocket upgrade to ${url} rejected by server (HTTP ${res.statusCode})`));
208
+ const message = `WebSocket upgrade to ${url} rejected by server (HTTP ${res.statusCode})`;
209
+ if (RETRYABLE_HANDSHAKE_STATUS_CODES.has(res.statusCode ?? 0)) {
210
+ reject(new LangSmithSandboxRetryableConnectionError(message, retryAfterSeconds(res.headers)));
211
+ }
212
+ else {
213
+ reject(new LangSmithSandboxConnectionError(message));
214
+ }
205
215
  });
206
216
  // Stays attached after settling so a late error has a listener and cannot
207
217
  // become an unhandled 'error' event.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
5
5
  "packageManager": "pnpm@10.33.0",
6
6
  "files": [
@@ -168,7 +168,7 @@
168
168
  "@anthropic-ai/sdk": "^0.98.0",
169
169
  "@babel/preset-env": "^8.0.2",
170
170
  "@earendil-works/pi-coding-agent": "0.80.10",
171
- "@faker-js/faker": "^8.4.1",
171
+ "@faker-js/faker": "^10.5.0",
172
172
  "@google/genai": "^2.0.1",
173
173
  "@jest/globals": "^30.4.1",
174
174
  "@jest/reporters": "^30.2.0",
@@ -192,6 +192,7 @@
192
192
  "@typescript-eslint/parser": "^8.62.1",
193
193
  "ai": "7.0.36",
194
194
  "babel-jest": "^30.2.0",
195
+ "browserslist": "4.28.7",
195
196
  "cross-env": "^10.1.0",
196
197
  "dotenv": "^17.3.1",
197
198
  "jest": "^29.5.0",
@@ -485,7 +486,7 @@
485
486
  "brace-expansion@<1.1.16": "1.1.16",
486
487
  "brace-expansion@>=2.0.0 <2.1.2": "2.1.2",
487
488
  "brace-expansion@>=3.0.0 <5.0.7": "5.0.7",
488
- "fast-uri": "3.1.5",
489
+ "fast-uri": "3.1.6",
489
490
  "postcss": "8.5.23",
490
491
  "js-yaml": "4.3.1",
491
492
  "hono": "4.12.34",