@narumitw/pi-otel 0.55.1 → 0.55.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  Versions through 0.54.3 were released as `@narumitw/pi-langfuse`.
4
4
 
5
+ ## 0.55.2
6
+
7
+ ### Patch Changes
8
+
9
+ - 648e3ab: Reuse the context usage snapshot when an automatic continuation opens a new trace at turn start, avoiding a second history scan without changing trace metadata.
10
+ - Updated dependencies [1cbb470]
11
+ - @narumitw/pi-tui-kit@0.71.0
12
+
5
13
  ## 0.55.1
6
14
 
7
15
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1190,7 +1190,7 @@ function createPiLangfuseSessionController(options) {
1190
1190
  const recorder = activeRecorder();
1191
1191
  if (!recorder) return;
1192
1192
  lastSnapshot = contextSnapshot(ctx);
1193
- ensureActiveRun(recorder, ctx, startRootTrace);
1193
+ ensureActiveRun(recorder, ctx, startRootTrace, lastSnapshot);
1194
1194
  recorder.beginTurn(event.turnIndex);
1195
1195
  });
1196
1196
  pi.on("before_provider_request", (event, ctx) => {
@@ -1365,13 +1365,13 @@ function snapshotSessionOptions(options) {
1365
1365
  ...options.metadata ? { metadata: { ...options.metadata } } : {}
1366
1366
  };
1367
1367
  }
1368
- function ensureActiveRun(recorder, ctx, startRootTrace) {
1368
+ function ensureActiveRun(recorder, ctx, startRootTrace, observedSnapshot) {
1369
1369
  if (!recorder.hasActiveTrace()) {
1370
1370
  startRootTrace((nextRequestId) => {
1371
1371
  recorder.beginAgent({
1372
1372
  prompt: "[automatic continuation]",
1373
1373
  model: ctx.model ? { provider: ctx.model.provider, id: ctx.model.id, api: ctx.model.api } : void 0,
1374
- snapshot: contextSnapshot(ctx),
1374
+ snapshot: observedSnapshot ?? contextSnapshot(ctx),
1375
1375
  ...nextRequestId ? { requestId: nextRequestId } : {}
1376
1376
  });
1377
1377
  });