pi-langfuse 1.5.3 → 1.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-langfuse",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "Langfuse extension for Pi coding agent",
5
5
  "repository": {
6
6
  "type": "git",
@@ -184,7 +184,7 @@ export async function finishGenerationFromMessage(event: Record<string, unknown>
184
184
  model: model || undefined,
185
185
  modelParameters,
186
186
  usageDetails,
187
- costDetails,
187
+ ...(costDetails ? { costDetails } : {}),
188
188
  metadata: {
189
189
  ...generation.metadata,
190
190
  finishReason: message.finishReason ?? message.stopReason ?? event.finishReason,
@@ -232,7 +232,7 @@ export async function createFallbackGenerationFromTurn(event: Record<string, unk
232
232
  model: model || undefined,
233
233
  modelParameters,
234
234
  usageDetails,
235
- costDetails,
235
+ ...(costDetails ? { costDetails } : {}),
236
236
  metadata: captured.metadata,
237
237
  },
238
238
  asType: "generation",
package/src/utils.ts CHANGED
@@ -400,6 +400,9 @@ export function extractCostDetails(messageOrEvent: Record<string, unknown>): Rec
400
400
  const input = Number(cost.input ?? cost.inputCost ?? 0);
401
401
  const output = Number(cost.output ?? cost.outputCost ?? 0);
402
402
  const total = Number(cost.total ?? cost.totalCost ?? input + output);
403
+ if (input === 0 && output === 0 && total === 0) {
404
+ return undefined;
405
+ }
403
406
 
404
407
  return { input, output, total };
405
408
  }