@posthog/ai 8.6.0 → 8.6.1

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.
@@ -299,7 +299,7 @@ function addDefaults(params) {
299
299
  };
300
300
  }
301
301
 
302
- var version = "8.6.0";
302
+ var version = "8.6.1";
303
303
 
304
304
  const DEFAULT_MAX_DEPTH = 3;
305
305
  const MAX_STACK_LINES = 20;
@@ -291,7 +291,7 @@ function addDefaults(params) {
291
291
  };
292
292
  }
293
293
 
294
- var version = "8.6.0";
294
+ var version = "8.6.1";
295
295
 
296
296
  const DEFAULT_MAX_DEPTH = 3;
297
297
  const MAX_STACK_LINES = 20;
@@ -384,7 +384,7 @@ function addDefaults(params) {
384
384
  };
385
385
  }
386
386
 
387
- var version = "8.6.0";
387
+ var version = "8.6.1";
388
388
 
389
389
  const DEFAULT_MAX_DEPTH = 3;
390
390
  const MAX_STACK_LINES = 20;
@@ -380,7 +380,7 @@ function addDefaults(params) {
380
380
  };
381
381
  }
382
382
 
383
- var version = "8.6.0";
383
+ var version = "8.6.1";
384
384
 
385
385
  const DEFAULT_MAX_DEPTH = 3;
386
386
  const MAX_STACK_LINES = 20;
package/dist/index.cjs CHANGED
@@ -380,7 +380,7 @@ function sanitizeValues(obj) {
380
380
  return jsonSafe;
381
381
  }
382
382
 
383
- var version = "8.6.0";
383
+ var version = "8.6.1";
384
384
 
385
385
  const DEFAULT_MAX_DEPTH = 3;
386
386
  const MAX_STACK_LINES = 20;
package/dist/index.mjs CHANGED
@@ -378,7 +378,7 @@ function sanitizeValues(obj) {
378
378
  return jsonSafe;
379
379
  }
380
380
 
381
- var version = "8.6.0";
381
+ var version = "8.6.1";
382
382
 
383
383
  const DEFAULT_MAX_DEPTH = 3;
384
384
  const MAX_STACK_LINES = 20;
@@ -217,7 +217,7 @@ function sanitizeValues(obj) {
217
217
  return jsonSafe;
218
218
  }
219
219
 
220
- var version = "8.6.0";
220
+ var version = "8.6.1";
221
221
 
222
222
  const DEFAULT_MAX_DEPTH = 3;
223
223
  const MAX_STACK_LINES = 20;
@@ -308,6 +308,13 @@ const warnIfPostHogAiGateway = baseURL => {
308
308
  console.warn('[PostHog] The PostHog AI wrapper is pointed at the PostHog AI Gateway. ' + 'Both capture $ai_generation, so every call is double-counted and double-billed. ' + `Use one or the other — see ${GATEWAY_DOCS_URL}.`);
309
309
  };
310
310
 
311
+ // Mirror LangGraph's isGraphBubbleUp guard without adding LangGraph as a dependency. Every
312
+ // LangGraph control-flow exception (GraphInterrupt, NodeInterrupt, ParentCommand, GraphDrained,
313
+ // and future subclasses) exposes a prototype getter `is_bubble_up` that returns true, which the
314
+ // LangGraph runtime itself uses to distinguish control flow from real failures. The getter reads
315
+ // as undefined on ordinary Errors and works across duplicated LangGraph package copies.
316
+ const isLangGraphControlFlow = error => error.is_bubble_up === true;
317
+
311
318
  /** A run may either be a Span or a Generation */
312
319
 
313
320
  /** Storage for run metadata */
@@ -559,8 +566,20 @@ class LangChainCallbackHandler extends base.BaseCallbackHandler {
559
566
  eventProperties['$process_person_profile'] = false;
560
567
  }
561
568
  if (outputs instanceof Error) {
562
- eventProperties['$ai_error'] = stringifyError(outputs);
563
- eventProperties['$ai_is_error'] = true;
569
+ if (isLangGraphControlFlow(outputs)) {
570
+ // GraphInterrupt carries the pending interrupts (e.g. the question posed to a human).
571
+ // Surface them under the same `__interrupt__` key LangGraph hands back to the caller,
572
+ // so an interrupted span stays distinguishable from a node that returned nothing.
573
+ const interrupts = outputs.interrupts;
574
+ if (interrupts !== undefined) {
575
+ eventProperties['$ai_output_state'] = withPrivacyMode(this.client, this.privacyMode, sanitizeLangChain({
576
+ __interrupt__: interrupts
577
+ }));
578
+ }
579
+ } else {
580
+ eventProperties['$ai_error'] = stringifyError(outputs);
581
+ eventProperties['$ai_is_error'] = true;
582
+ }
564
583
  } else if (outputs !== undefined) {
565
584
  eventProperties['$ai_output_state'] = withPrivacyMode(this.client, this.privacyMode, sanitizeLangChain(outputs));
566
585
  }