feat(tracing): Integrate Langfuse for LLM call tracing and add documentation

This commit is contained in:
Willie Zutz 2025-08-10 10:05:42 -06:00
parent 9670003970
commit 7b4a7a531e
17 changed files with 183 additions and 36 deletions

View file

@ -19,6 +19,7 @@ import {
import { formatDateForLLM } from '../utils';
import { getModelName } from '../utils/modelUtils';
import { removeThinkingBlocks } from '../utils/contentUtils';
import { getLangfuseCallbacks } from '@/lib/tracing/langfuse';
/**
* Normalize usage metadata from different LLM providers
@ -511,12 +512,14 @@ Use all available tools strategically to provide comprehensive, well-researched,
},
recursionLimit: 25, // Allow sufficient iterations for tool use
signal: this.signal,
...getLangfuseCallbacks(),
};
// Use streamEvents to capture both tool calls and token-level streaming
const eventStream = agent.streamEvents(initialState, {
...config,
version: 'v2',
...getLangfuseCallbacks(),
});
let finalResult: any = null;