🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(pydantic-ai): tool call mapping in OtelIngestionProcessor (#9524)
Ron Vergisd6b0e66ae973
diff --git a/packages/shared/src/server/otel/OtelIngestionProcessor.ts b/packages/shared/src/server/otel/OtelIngestionProcessor.tsindex 817a713e9d..07296fedbf 100644--- a/packages/shared/src/server/otel/OtelIngestionProcessor.ts+++ b/packages/shared/src/server/otel/OtelIngestionProcessor.ts@@ -1385,6 +1385,13 @@ export class OtelIngestionProcessor {return { input, output, filteredAttributes };}+ // Pydantic-AI uses tool_arguments and tool_response for tool call input/output+ input = attributes["tool_arguments"];+ output = attributes["tool_response"];+ if (input || output) {+ return { input, output, filteredAttributes };+ }+// TraceLoop uses attributes propertyconst inputAttributes = Object.keys(attributes).filter((key) =>key.startsWith("gen_ai.prompt"),diff --git a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts b/web/src/__tests__/server/api/otel/otelMapping.servertest.tsindex 8e272eedc6..1265ef6890 100644--- a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts+++ b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts@@ -2153,6 +2153,32 @@ describe("OTel Resource Span Mapping", () => {entityAttributeValue: '{"foo": "bar"}',},],+ [+ "should map pydantic-ai tool_arguments to input",+ {+ entity: "observation",+ otelAttributeKey: "tool_arguments",+ otelAttributeValue: {+ stringValue:+ '{"query": "What is the weather like?", "location": "New York"}',+ },+ entityAttributeKey: "input",+ entityAttributeValue:+ '{"query": "What is the weather like?", "location": "New York"}',+ },+ ],+ [+ "should map pydantic-ai tool_response to output",+ {+ entity: "observation",+ otelAttributeKey: "tool_response",+ otelAttributeValue: {+ stringValue: '{"result": "Sunny, 22°C"}',+ },+ entityAttributeKey: "output",+ entityAttributeValue: '{"result": "Sunny, 22°C"}',+ },+ ],["should map lk.input_text to input",{