🪢 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
feat(tracing): render pydantic tool calls beautifully (#10929)
Nimaracbdb1288dcb
diff --git a/packages/shared/scripts/seeder/utils/framework-traces/pydantic-ai-tools-2025-12-04.json b/packages/shared/scripts/seeder/utils/framework-traces/pydantic-ai-tools-2025-12-04.jsonnew file mode 100644index 0000000000..9d13b71077--- /dev/null+++ b/packages/shared/scripts/seeder/utils/framework-traces/pydantic-ai-tools-2025-12-04.json@@ -0,0 +1,1863 @@+{+ "trace": {+ "id": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "name": "joke-generator",+ "timestamp": "2025-12-04T14:51:22.053Z",+ "environment": "default",+ "tags": [+ "example",+ "joke-generator"+ ],+ "bookmarked": false,+ "release": null,+ "version": null,+ "userId": null,+ "sessionId": null,+ "public": false,+ "input": "\"{\\\"args\\\": [\\\"programming\\\"], \\\"kwargs\\\": {}}\"",+ "output": "\"Why do programmers hate nature? \\nIt has too many bugs!\"",+ "createdAt": "2025-12-04T14:51:25.697Z",+ "updatedAt": "2025-12-04T14:51:29.610Z",+ "metadata": "{\"environment\":\"development\",\"topic\":\"programming\",\"iterations\":1,\"evaluation\":{\"quality\":\"good\",\"feedback\":\"The joke is clever and plays on the double meaning of 'bugs' in programming and nature. It's relatable for those in the tech field, making it effective. To enhance it, consider adding a punchline that builds on the setup for an even stronger impact.\"},\"resourceAttributes\":{\"telemetry.sdk.language\":\"python\",\"telemetry.sdk.name\":\"opentelemetry\",\"telemetry.sdk.version\":\"1.38.0\",\"service.name\":\"unknown_service\"},\"scope\":{\"name\":\"langfuse-sdk\",\"version\":\"3.10.5\",\"attributes\":{\"public_key\":\"pk-lf-1234567890\"}}}",+ "scores": [],+ "latency": 7.424+ },+ "observations": [+ {+ "id": "00d3f40ee8e3b716",+ "traceId": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "startTime": "2025-12-04T14:51:22.049Z",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "parentObservationId": null,+ "type": "SPAN",+ "environment": "default",+ "endTime": "2025-12-04T14:51:29.473Z",+ "name": "run_joke_generator",+ "level": "DEFAULT",+ "statusMessage": null,+ "version": null,+ "createdAt": "2025-12-04T14:51:29.574Z",+ "updatedAt": "2025-12-04T14:51:29.586Z",+ "model": null,+ "internalModelId": null,+ "modelParameters": null,+ "completionStartTime": null,+ "promptId": null,+ "promptName": null,+ "promptVersion": null,+ "latency": 7424,+ "timeToFirstToken": null,+ "usageDetails": {},+ "costDetails": {},+ "providedCostDetails": {},+ "inputCost": null,+ "outputCost": null,+ "totalCost": 0,+ "inputUsage": 0,+ "outputUsage": 0,+ "totalUsage": 0,+ "usagePricingTierId": null,+ "usagePricingTierName": null,+ "metadata": {+ "resourceAttributes": {+ "telemetry.sdk.language": "python",+ "telemetry.sdk.name": "opentelemetry",+ "telemetry.sdk.version": "1.38.0",+ "service.name": "unknown_service"+ },+ "scope": {+ "name": "langfuse-sdk",+ "version": "3.10.5",+ "attributes": {+ "public_key": "pk-lf-1234567890"+ }+ }+ },+ "input": {+ "args": [+ "programming"+ ],+ "kwargs": {}+ },+ "output": {+ "joke": "Why do programmers hate nature? \nIt has too many bugs!",+ "evaluation": {+ "quality": "good",+ "feedback": "The joke is clever and plays on the double meaning of 'bugs' in programming and nature. It's relatable for those in the tech field, making it effective. To enhance it, consider adding a punchline that builds on the setup for an even stronger impact."+ },+ "iterations": 1,+ "success": true+ }+ },+ {+ "id": "49ae06cbfa06611f",+ "traceId": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "startTime": "2025-12-04T14:51:26.132Z",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "parentObservationId": "00d3f40ee8e3b716",+ "type": "SPAN",+ "environment": "default",+ "endTime": "2025-12-04T14:51:27.417Z",+ "name": "joke_agent run",+ "level": "DEFAULT",+ "statusMessage": null,+ "version": null,+ "createdAt": "2025-12-04T14:51:29.574Z",+ "updatedAt": "2025-12-04T14:51:29.586Z",+ "model": null,+ "internalModelId": null,+ "modelParameters": null,+ "completionStartTime": null,+ "promptId": null,+ "promptName": null,+ "promptVersion": null,+ "latency": 1285,+ "timeToFirstToken": null,+ "usageDetails": {},+ "costDetails": {},+ "providedCostDetails": {},+ "inputCost": null,+ "outputCost": null,+ "totalCost": 0,+ "inputUsage": 0,+ "outputUsage": 0,+ "totalUsage": 0,+ "usagePricingTierId": null,+ "usagePricingTierName": null,+ "metadata": {+ "attributes": {+ "model_name": "gpt-4o-mini",+ "agent_name": "joke_agent",+ "gen_ai.agent.name": "joke_agent",+ "logfire.msg": "joke_agent run",+ "final_result": "Why do programmers hate nature? \nIt has too many bugs!",+ "gen_ai.usage.input_tokens": "502",+ "gen_ai.usage.output_tokens": "14",+ "pydantic_ai.all_messages": [+ {+ "role": "system",+ "parts": [+ {+ "type": "text",+ "content": "You are a creative joke writer. When asked to get inspiration, you will call THREE of the available suggestion tools to gather ideas. When asked to write a joke, create a funny joke based on the suggestions you received."+ }+ ]+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "text",+ "content": "Select and call THREE of the available tools to get joke suggestions about 'programming'."+ }+ ]+ },+ {+ "role": "assistant",+ "parts": [+ {+ "type": "tool_call",+ "id": "call_X0OSgjUukT5inyEQvuZQnHrk",+ "name": "get_pun_suggestion",+ "arguments": {+ "topic": "programming"+ }+ },+ {+ "type": "tool_call",+ "id": "call_WxZcCvSDhGT4RJHlcU01k10x",+ "name": "get_dad_joke_suggestion",+ "arguments": {+ "topic": "programming"+ }+ },+ {+ "type": "tool_call",+ "id": "call_aRaObiWKKt6GzgDkkUl3bu1Q",+ "name": "get_one_liner_suggestion",+ "arguments": {+ "topic": "programming"+ }+ }+ ],+ "finish_reason": "tool_call"+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "tool_call_response",+ "id": "call_X0OSgjUukT5inyEQvuZQnHrk",+ "name": "get_pun_suggestion",+ "result": "Pun idea: Play on words related to 'programming' - think about homophones or double meanings"+ },+ {+ "type": "tool_call_response",+ "id": "call_WxZcCvSDhGT4RJHlcU01k10x",+ "name": "get_dad_joke_suggestion",+ "result": "Dad joke idea: Use a classic setup-punchline format about 'programming' with a groan-worthy twist"+ },+ {+ "type": "tool_call_response",+ "id": "call_aRaObiWKKt6GzgDkkUl3bu1Q",+ "name": "get_one_liner_suggestion",+ "result": "One-liner idea: Make a quick, witty observation about 'programming' in a single sentence"+ }+ ]+ },+ {+ "role": "assistant",+ "parts": [+ {+ "type": "text",+ "content": "I gathered some great ideas for a programming joke! Here’s a funny joke combining those suggestions:\n\nWhy do programmers prefer dark mode? \nBecause light attracts bugs! \n\n(It's a pun on light attracting bugs and programmers having a love-hate relationship with debugging!)"+ }+ ],+ "finish_reason": "stop"+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "text",+ "content": "Now write a funny joke about 'programming' based on the suggestions you received. Just output the joke, nothing else."+ }+ ]+ },+ {+ "role": "assistant",+ "parts": [+ {+ "type": "text",+ "content": "Why do programmers hate nature? \nIt has too many bugs!"+ }+ ],+ "finish_reason": "stop"+ }+ ],+ "pydantic_ai.new_message_index": "4",+ "logfire.json_schema": {+ "type": "object",+ "properties": {+ "pydantic_ai.all_messages": {+ "type": "array"+ },+ "pydantic_ai.new_message_index": {},+ "final_result": {+ "type": "object"+ }+ }+ }+ },+ "resourceAttributes": {+ "telemetry.sdk.language": "python",+ "telemetry.sdk.name": "opentelemetry",+ "telemetry.sdk.version": "1.38.0",+ "service.name": "unknown_service"+ },+ "scope": {+ "name": "pydantic-ai",+ "version": "1.26.0",+ "attributes": {}+ }+ },+ "input": null,+ "output": null+ },+ {+ "id": "00d2804abb764b1b",+ "traceId": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "startTime": "2025-12-04T14:51:24.423Z",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "parentObservationId": "5b5c52d029f28206",+ "type": "GENERATION",+ "environment": "default",+ "endTime": "2025-12-04T14:51:26.130Z",+ "name": "chat gpt-4o-mini",+ "level": "DEFAULT",+ "statusMessage": null,+ "version": null,+ "createdAt": "2025-12-04T14:51:29.574Z",+ "updatedAt": "2025-12-04T14:51:29.585Z",+ "model": "gpt-4o-mini-2024-07-18",+ "internalModelId": "clyrjpbe20000t0mzcbwc42rg",+ "modelParameters": {+ "temperature": 0.7+ },+ "completionStartTime": null,+ "promptId": null,+ "promptName": null,+ "promptVersion": null,+ "latency": 1707,+ "timeToFirstToken": null,+ "usageDetails": {+ "input": 417,+ "output": 53,+ "total": 470+ },+ "costDetails": {+ "input": 0.00006255,+ "output": 0.0000318,+ "total": 0.00009435+ },+ "providedCostDetails": {},+ "inputCost": 0.00006255,+ "outputCost": 0.0000318,+ "totalCost": 0.00009435,+ "inputUsage": 417,+ "outputUsage": 53,+ "totalUsage": 470,+ "usagePricingTierId": "clyrjpbe20000t0mzcbwc42rg_tier_default",+ "usagePricingTierName": "Standard",+ "metadata": {+ "attributes": {+ "gen_ai.operation.name": "chat",+ "gen_ai.system": "openai",+ "gen_ai.request.model": "gpt-4o-mini",+ "server.address": "api.openai.com",+ "model_request_parameters": {+ "function_tools": [+ {+ "name": "get_pun_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a pun-style joke suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ },+ {+ "name": "get_dad_joke_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a dad joke style suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ },+ {+ "name": "get_one_liner_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a one-liner joke suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ },+ {+ "name": "get_car_joke_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a car-themed joke suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ },+ {+ "name": "get_tree_joke_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a tree-themed joke suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ }+ ],+ "builtin_tools": [],+ "output_mode": "text",+ "output_object": null,+ "output_tools": [],+ "prompted_output_template": null,+ "allow_text_output": true,+ "allow_image_output": false+ },+ "gen_ai.request.temperature": "0.7",+ "logfire.json_schema": {+ "type": "object",+ "properties": {+ "gen_ai.input.messages": {+ "type": "array"+ },+ "gen_ai.output.messages": {+ "type": "array"+ },+ "model_request_parameters": {+ "type": "object"+ }+ }+ },+ "gen_ai.usage.input_tokens": "417",+ "gen_ai.usage.output_tokens": "53",+ "gen_ai.response.model": "gpt-4o-mini-2024-07-18",+ "operation.cost": "0.00009435",+ "gen_ai.response.id": "chatcmpl-Cj4xwF0fLMbLL7cj2PpKMa69vdqgM",+ "gen_ai.response.finish_reasons": [+ "stop"+ ]+ },+ "resourceAttributes": {+ "telemetry.sdk.language": "python",+ "telemetry.sdk.name": "opentelemetry",+ "telemetry.sdk.version": "1.38.0",+ "service.name": "unknown_service"+ },+ "scope": {+ "name": "pydantic-ai",+ "version": "1.26.0",+ "attributes": {}+ }+ },+ "input": [+ {+ "role": "system",+ "parts": [+ {+ "type": "text",+ "content": "You are a creative joke writer. When asked to get inspiration, you will call THREE of the available suggestion tools to gather ideas. When asked to write a joke, create a funny joke based on the suggestions you received."+ }+ ]+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "text",+ "content": "Select and call THREE of the available tools to get joke suggestions about 'programming'."+ }+ ]+ },+ {+ "role": "assistant",+ "parts": [+ {+ "type": "tool_call",+ "id": "call_X0OSgjUukT5inyEQvuZQnHrk",+ "name": "get_pun_suggestion",+ "arguments": {+ "topic": "programming"+ }+ },+ {+ "type": "tool_call",+ "id": "call_WxZcCvSDhGT4RJHlcU01k10x",+ "name": "get_dad_joke_suggestion",+ "arguments": {+ "topic": "programming"+ }+ },+ {+ "type": "tool_call",+ "id": "call_aRaObiWKKt6GzgDkkUl3bu1Q",+ "name": "get_one_liner_suggestion",+ "arguments": {+ "topic": "programming"+ }+ }+ ],+ "finish_reason": "tool_call"+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "tool_call_response",+ "id": "call_X0OSgjUukT5inyEQvuZQnHrk",+ "name": "get_pun_suggestion",+ "result": "Pun idea: Play on words related to 'programming' - think about homophones or double meanings"+ },+ {+ "type": "tool_call_response",+ "id": "call_WxZcCvSDhGT4RJHlcU01k10x",+ "name": "get_dad_joke_suggestion",+ "result": "Dad joke idea: Use a classic setup-punchline format about 'programming' with a groan-worthy twist"+ },+ {+ "type": "tool_call_response",+ "id": "call_aRaObiWKKt6GzgDkkUl3bu1Q",+ "name": "get_one_liner_suggestion",+ "result": "One-liner idea: Make a quick, witty observation about 'programming' in a single sentence"+ }+ ]+ }+ ],+ "output": [+ {+ "role": "assistant",+ "parts": [+ {+ "type": "text",+ "content": "I gathered some great ideas for a programming joke! Here’s a funny joke combining those suggestions:\n\nWhy do programmers prefer dark mode? \nBecause light attracts bugs! \n\n(It's a pun on light attracting bugs and programmers having a love-hate relationship with debugging!)"+ }+ ],+ "finish_reason": "stop"+ }+ ]+ },+ {+ "id": "eb0cc14cf7943ad5",+ "traceId": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "startTime": "2025-12-04T14:51:27.422Z",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "parentObservationId": "227eb5c856efa3d3",+ "type": "GENERATION",+ "environment": "default",+ "endTime": "2025-12-04T14:51:29.472Z",+ "name": "chat gpt-4o-mini",+ "level": "DEFAULT",+ "statusMessage": null,+ "version": null,+ "createdAt": "2025-12-04T14:51:29.574Z",+ "updatedAt": "2025-12-04T14:51:29.585Z",+ "model": "gpt-4o-mini-2024-07-18",+ "internalModelId": "clyrjpbe20000t0mzcbwc42rg",+ "modelParameters": {+ "temperature": 0+ },+ "completionStartTime": null,+ "promptId": null,+ "promptName": null,+ "promptVersion": null,+ "latency": 2050,+ "timeToFirstToken": null,+ "usageDetails": {+ "input": 131,+ "output": 69,+ "total": 200+ },+ "costDetails": {+ "input": 0.00001965,+ "output": 0.0000414,+ "total": 0.000061049999+ },+ "providedCostDetails": {},+ "inputCost": 0.00001965,+ "outputCost": 0.0000414,+ "totalCost": 0.000061049999,+ "inputUsage": 131,+ "outputUsage": 69,+ "totalUsage": 200,+ "usagePricingTierId": "clyrjpbe20000t0mzcbwc42rg_tier_default",+ "usagePricingTierName": "Standard",+ "metadata": {+ "attributes": {+ "gen_ai.operation.name": "chat",+ "gen_ai.system": "openai",+ "gen_ai.request.model": "gpt-4o-mini",+ "server.address": "api.openai.com",+ "model_request_parameters": {+ "function_tools": [],+ "builtin_tools": [],+ "output_mode": "tool",+ "output_object": null,+ "output_tools": [+ {+ "name": "final_result",+ "parameters_json_schema": {+ "properties": {+ "quality": {+ "description": "Rate the joke quality: 'good' if funny and well-crafted, 'okay' if decent but needs refinement, 'bad' if not funny",+ "enum": [+ "good",+ "okay",+ "bad"+ ],+ "type": "string"+ },+ "feedback": {+ "description": "Specific feedback on how to improve the joke",+ "type": "string"+ }+ },+ "required": [+ "quality",+ "feedback"+ ],+ "type": "object",+ "additionalProperties": false+ },+ "description": "The final response which ends this conversation",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "output",+ "metadata": null+ }+ ],+ "prompted_output_template": null,+ "allow_text_output": false,+ "allow_image_output": false+ },+ "gen_ai.request.temperature": "0",+ "logfire.json_schema": {+ "type": "object",+ "properties": {+ "gen_ai.input.messages": {+ "type": "array"+ },+ "gen_ai.output.messages": {+ "type": "array"+ },+ "model_request_parameters": {+ "type": "object"+ }+ }+ },+ "gen_ai.usage.input_tokens": "131",+ "gen_ai.usage.output_tokens": "69",+ "gen_ai.response.model": "gpt-4o-mini-2024-07-18",+ "operation.cost": "0.00006105",+ "gen_ai.response.id": "chatcmpl-Cj4xzvxxhTcFqIdven62KgHXNPUCI",+ "gen_ai.response.finish_reasons": [+ "tool_call"+ ]+ },+ "resourceAttributes": {+ "telemetry.sdk.language": "python",+ "telemetry.sdk.name": "opentelemetry",+ "telemetry.sdk.version": "1.38.0",+ "service.name": "unknown_service"+ },+ "scope": {+ "name": "pydantic-ai",+ "version": "1.26.0",+ "attributes": {}+ }+ },+ "input": [+ {+ "role": "system",+ "parts": [+ {+ "type": "text",+ "content": "You are a joke critic. Evaluate if the joke is funny and well-crafted."+ }+ ]+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "text",+ "content": "Rate this joke:\n\nWhy do programmers hate nature? \nIt has too many bugs!"+ }+ ]+ }+ ],+ "output": [+ {+ "role": "assistant",+ "parts": [+ {+ "type": "tool_call",+ "id": "call_ZuzwalMMtvv9BC6xlVe3fiBP",+ "name": "final_result",+ "arguments": {+ "quality": "good",+ "feedback": "The joke is clever and plays on the double meaning of 'bugs' in programming and nature. It's relatable for those in the tech field, making it effective. To enhance it, consider adding a punchline that builds on the setup for an even stronger impact."+ }+ }+ ],+ "finish_reason": "tool_call"+ }+ ]+ },+ {+ "id": "5b5c52d029f28206",+ "traceId": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "startTime": "2025-12-04T14:51:22.050Z",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "parentObservationId": "00d3f40ee8e3b716",+ "type": "SPAN",+ "environment": "default",+ "endTime": "2025-12-04T14:51:26.131Z",+ "name": "joke_agent run",+ "level": "DEFAULT",+ "statusMessage": null,+ "version": null,+ "createdAt": "2025-12-04T14:51:29.574Z",+ "updatedAt": "2025-12-04T14:51:29.585Z",+ "model": null,+ "internalModelId": null,+ "modelParameters": null,+ "completionStartTime": null,+ "promptId": null,+ "promptName": null,+ "promptVersion": null,+ "latency": 4081,+ "timeToFirstToken": null,+ "usageDetails": {},+ "costDetails": {},+ "providedCostDetails": {},+ "inputCost": null,+ "outputCost": null,+ "totalCost": 0,+ "inputUsage": 0,+ "outputUsage": 0,+ "totalUsage": 0,+ "usagePricingTierId": null,+ "usagePricingTierName": null,+ "metadata": {+ "attributes": {+ "model_name": "gpt-4o-mini",+ "agent_name": "joke_agent",+ "gen_ai.agent.name": "joke_agent",+ "logfire.msg": "joke_agent run",+ "final_result": "I gathered some great ideas for a programming joke! Here’s a funny joke combining those suggestions:\n\nWhy do programmers prefer dark mode? \nBecause light attracts bugs! \n\n(It's a pun on light attracting bugs and programmers having a love-hate relationship with debugging!)",+ "gen_ai.usage.input_tokens": "682",+ "gen_ai.usage.output_tokens": "126",+ "pydantic_ai.all_messages": [+ {+ "role": "system",+ "parts": [+ {+ "type": "text",+ "content": "You are a creative joke writer. When asked to get inspiration, you will call THREE of the available suggestion tools to gather ideas. When asked to write a joke, create a funny joke based on the suggestions you received."+ }+ ]+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "text",+ "content": "Select and call THREE of the available tools to get joke suggestions about 'programming'."+ }+ ]+ },+ {+ "role": "assistant",+ "parts": [+ {+ "type": "tool_call",+ "id": "call_X0OSgjUukT5inyEQvuZQnHrk",+ "name": "get_pun_suggestion",+ "arguments": {+ "topic": "programming"+ }+ },+ {+ "type": "tool_call",+ "id": "call_WxZcCvSDhGT4RJHlcU01k10x",+ "name": "get_dad_joke_suggestion",+ "arguments": {+ "topic": "programming"+ }+ },+ {+ "type": "tool_call",+ "id": "call_aRaObiWKKt6GzgDkkUl3bu1Q",+ "name": "get_one_liner_suggestion",+ "arguments": {+ "topic": "programming"+ }+ }+ ],+ "finish_reason": "tool_call"+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "tool_call_response",+ "id": "call_X0OSgjUukT5inyEQvuZQnHrk",+ "name": "get_pun_suggestion",+ "result": "Pun idea: Play on words related to 'programming' - think about homophones or double meanings"+ },+ {+ "type": "tool_call_response",+ "id": "call_WxZcCvSDhGT4RJHlcU01k10x",+ "name": "get_dad_joke_suggestion",+ "result": "Dad joke idea: Use a classic setup-punchline format about 'programming' with a groan-worthy twist"+ },+ {+ "type": "tool_call_response",+ "id": "call_aRaObiWKKt6GzgDkkUl3bu1Q",+ "name": "get_one_liner_suggestion",+ "result": "One-liner idea: Make a quick, witty observation about 'programming' in a single sentence"+ }+ ]+ },+ {+ "role": "assistant",+ "parts": [+ {+ "type": "text",+ "content": "I gathered some great ideas for a programming joke! Here’s a funny joke combining those suggestions:\n\nWhy do programmers prefer dark mode? \nBecause light attracts bugs! \n\n(It's a pun on light attracting bugs and programmers having a love-hate relationship with debugging!)"+ }+ ],+ "finish_reason": "stop"+ }+ ],+ "logfire.json_schema": {+ "type": "object",+ "properties": {+ "pydantic_ai.all_messages": {+ "type": "array"+ },+ "final_result": {+ "type": "object"+ }+ }+ }+ },+ "resourceAttributes": {+ "telemetry.sdk.language": "python",+ "telemetry.sdk.name": "opentelemetry",+ "telemetry.sdk.version": "1.38.0",+ "service.name": "unknown_service"+ },+ "scope": {+ "name": "pydantic-ai",+ "version": "1.26.0",+ "attributes": {}+ }+ },+ "input": null,+ "output": null+ },+ {+ "id": "8976b072313c51f2",+ "traceId": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "startTime": "2025-12-04T14:51:26.133Z",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "parentObservationId": "49ae06cbfa06611f",+ "type": "GENERATION",+ "environment": "default",+ "endTime": "2025-12-04T14:51:27.416Z",+ "name": "chat gpt-4o-mini",+ "level": "DEFAULT",+ "statusMessage": null,+ "version": null,+ "createdAt": "2025-12-04T14:51:29.574Z",+ "updatedAt": "2025-12-04T14:51:29.584Z",+ "model": "gpt-4o-mini-2024-07-18",+ "internalModelId": "clyrjpbe20000t0mzcbwc42rg",+ "modelParameters": {+ "temperature": 0.7+ },+ "completionStartTime": null,+ "promptId": null,+ "promptName": null,+ "promptVersion": null,+ "latency": 1283,+ "timeToFirstToken": null,+ "usageDetails": {+ "input": 502,+ "output": 14,+ "total": 516+ },+ "costDetails": {+ "input": 0.0000753,+ "output": 0.0000084,+ "total": 0.0000837+ },+ "providedCostDetails": {},+ "inputCost": 0.0000753,+ "outputCost": 0.0000084,+ "totalCost": 0.0000837,+ "inputUsage": 502,+ "outputUsage": 14,+ "totalUsage": 516,+ "usagePricingTierId": "clyrjpbe20000t0mzcbwc42rg_tier_default",+ "usagePricingTierName": "Standard",+ "metadata": {+ "attributes": {+ "gen_ai.operation.name": "chat",+ "gen_ai.system": "openai",+ "gen_ai.request.model": "gpt-4o-mini",+ "server.address": "api.openai.com",+ "model_request_parameters": {+ "function_tools": [+ {+ "name": "get_pun_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a pun-style joke suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ },+ {+ "name": "get_dad_joke_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a dad joke style suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ },+ {+ "name": "get_one_liner_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a one-liner joke suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ },+ {+ "name": "get_car_joke_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a car-themed joke suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ },+ {+ "name": "get_tree_joke_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a tree-themed joke suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ }+ ],+ "builtin_tools": [],+ "output_mode": "text",+ "output_object": null,+ "output_tools": [],+ "prompted_output_template": null,+ "allow_text_output": true,+ "allow_image_output": false+ },+ "gen_ai.request.temperature": "0.7",+ "logfire.json_schema": {+ "type": "object",+ "properties": {+ "gen_ai.input.messages": {+ "type": "array"+ },+ "gen_ai.output.messages": {+ "type": "array"+ },+ "model_request_parameters": {+ "type": "object"+ }+ }+ },+ "gen_ai.usage.input_tokens": "502",+ "gen_ai.usage.output_tokens": "14",+ "gen_ai.response.model": "gpt-4o-mini-2024-07-18",+ "operation.cost": "0.0000837",+ "gen_ai.response.id": "chatcmpl-Cj4xysdHxD1EWQ6YHKdnqZ9dcX90X",+ "gen_ai.response.finish_reasons": [+ "stop"+ ]+ },+ "resourceAttributes": {+ "telemetry.sdk.language": "python",+ "telemetry.sdk.name": "opentelemetry",+ "telemetry.sdk.version": "1.38.0",+ "service.name": "unknown_service"+ },+ "scope": {+ "name": "pydantic-ai",+ "version": "1.26.0",+ "attributes": {}+ }+ },+ "input": [+ {+ "role": "system",+ "parts": [+ {+ "type": "text",+ "content": "You are a creative joke writer. When asked to get inspiration, you will call THREE of the available suggestion tools to gather ideas. When asked to write a joke, create a funny joke based on the suggestions you received."+ }+ ]+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "text",+ "content": "Select and call THREE of the available tools to get joke suggestions about 'programming'."+ }+ ]+ },+ {+ "role": "assistant",+ "parts": [+ {+ "type": "tool_call",+ "id": "call_X0OSgjUukT5inyEQvuZQnHrk",+ "name": "get_pun_suggestion",+ "arguments": {+ "topic": "programming"+ }+ },+ {+ "type": "tool_call",+ "id": "call_WxZcCvSDhGT4RJHlcU01k10x",+ "name": "get_dad_joke_suggestion",+ "arguments": {+ "topic": "programming"+ }+ },+ {+ "type": "tool_call",+ "id": "call_aRaObiWKKt6GzgDkkUl3bu1Q",+ "name": "get_one_liner_suggestion",+ "arguments": {+ "topic": "programming"+ }+ }+ ],+ "finish_reason": "tool_call"+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "tool_call_response",+ "id": "call_X0OSgjUukT5inyEQvuZQnHrk",+ "name": "get_pun_suggestion",+ "result": "Pun idea: Play on words related to 'programming' - think about homophones or double meanings"+ },+ {+ "type": "tool_call_response",+ "id": "call_WxZcCvSDhGT4RJHlcU01k10x",+ "name": "get_dad_joke_suggestion",+ "result": "Dad joke idea: Use a classic setup-punchline format about 'programming' with a groan-worthy twist"+ },+ {+ "type": "tool_call_response",+ "id": "call_aRaObiWKKt6GzgDkkUl3bu1Q",+ "name": "get_one_liner_suggestion",+ "result": "One-liner idea: Make a quick, witty observation about 'programming' in a single sentence"+ }+ ]+ },+ {+ "role": "assistant",+ "parts": [+ {+ "type": "text",+ "content": "I gathered some great ideas for a programming joke! Here’s a funny joke combining those suggestions:\n\nWhy do programmers prefer dark mode? \nBecause light attracts bugs! \n\n(It's a pun on light attracting bugs and programmers having a love-hate relationship with debugging!)"+ }+ ],+ "finish_reason": "stop"+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "text",+ "content": "Now write a funny joke about 'programming' based on the suggestions you received. Just output the joke, nothing else."+ }+ ]+ }+ ],+ "output": [+ {+ "role": "assistant",+ "parts": [+ {+ "type": "text",+ "content": "Why do programmers hate nature? \nIt has too many bugs!"+ }+ ],+ "finish_reason": "stop"+ }+ ]+ },+ {+ "id": "227eb5c856efa3d3",+ "traceId": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "startTime": "2025-12-04T14:51:27.420Z",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "parentObservationId": "00d3f40ee8e3b716",+ "type": "SPAN",+ "environment": "default",+ "endTime": "2025-12-04T14:51:29.473Z",+ "name": "evaluator_agent run",+ "level": "DEFAULT",+ "statusMessage": null,+ "version": null,+ "createdAt": "2025-12-04T14:51:29.574Z",+ "updatedAt": "2025-12-04T14:51:29.583Z",+ "model": null,+ "internalModelId": null,+ "modelParameters": null,+ "completionStartTime": null,+ "promptId": null,+ "promptName": null,+ "promptVersion": null,+ "latency": 2053,+ "timeToFirstToken": null,+ "usageDetails": {},+ "costDetails": {},+ "providedCostDetails": {},+ "inputCost": null,+ "outputCost": null,+ "totalCost": 0,+ "inputUsage": 0,+ "outputUsage": 0,+ "totalUsage": 0,+ "usagePricingTierId": null,+ "usagePricingTierName": null,+ "metadata": {+ "attributes": {+ "model_name": "gpt-4o-mini",+ "agent_name": "evaluator_agent",+ "gen_ai.agent.name": "evaluator_agent",+ "logfire.msg": "evaluator_agent run",+ "final_result": {+ "quality": "good",+ "feedback": "The joke is clever and plays on the double meaning of 'bugs' in programming and nature. It's relatable for those in the tech field, making it effective. To enhance it, consider adding a punchline that builds on the setup for an even stronger impact."+ },+ "gen_ai.usage.input_tokens": "131",+ "gen_ai.usage.output_tokens": "69",+ "pydantic_ai.all_messages": [+ {+ "role": "system",+ "parts": [+ {+ "type": "text",+ "content": "You are a joke critic. Evaluate if the joke is funny and well-crafted."+ }+ ]+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "text",+ "content": "Rate this joke:\n\nWhy do programmers hate nature? \nIt has too many bugs!"+ }+ ]+ },+ {+ "role": "assistant",+ "parts": [+ {+ "type": "tool_call",+ "id": "call_ZuzwalMMtvv9BC6xlVe3fiBP",+ "name": "final_result",+ "arguments": {+ "quality": "good",+ "feedback": "The joke is clever and plays on the double meaning of 'bugs' in programming and nature. It's relatable for those in the tech field, making it effective. To enhance it, consider adding a punchline that builds on the setup for an even stronger impact."+ }+ }+ ],+ "finish_reason": "tool_call"+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "tool_call_response",+ "id": "call_ZuzwalMMtvv9BC6xlVe3fiBP",+ "name": "final_result",+ "result": "Final result processed."+ }+ ]+ }+ ],+ "logfire.json_schema": {+ "type": "object",+ "properties": {+ "pydantic_ai.all_messages": {+ "type": "array"+ },+ "final_result": {+ "type": "object"+ }+ }+ }+ },+ "resourceAttributes": {+ "telemetry.sdk.language": "python",+ "telemetry.sdk.name": "opentelemetry",+ "telemetry.sdk.version": "1.38.0",+ "service.name": "unknown_service"+ },+ "scope": {+ "name": "pydantic-ai",+ "version": "1.26.0",+ "attributes": {}+ }+ },+ "input": null,+ "output": null+ },+ {+ "id": "be64c23f44dd98be",+ "traceId": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "startTime": "2025-12-04T14:51:22.053Z",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "parentObservationId": "5b5c52d029f28206",+ "type": "GENERATION",+ "environment": "default",+ "endTime": "2025-12-04T14:51:24.415Z",+ "name": "chat gpt-4o-mini",+ "level": "DEFAULT",+ "statusMessage": null,+ "version": null,+ "createdAt": "2025-12-04T14:51:25.691Z",+ "updatedAt": "2025-12-04T14:51:25.729Z",+ "model": "gpt-4o-mini-2024-07-18",+ "internalModelId": "clyrjpbe20000t0mzcbwc42rg",+ "modelParameters": {+ "temperature": 0.7+ },+ "completionStartTime": null,+ "promptId": null,+ "promptName": null,+ "promptVersion": null,+ "latency": 2362,+ "timeToFirstToken": null,+ "usageDetails": {+ "input": 265,+ "output": 73,+ "total": 338+ },+ "costDetails": {+ "input": 0.00003975,+ "output": 0.0000438,+ "total": 0.00008355+ },+ "providedCostDetails": {},+ "inputCost": 0.00003975,+ "outputCost": 0.0000438,+ "totalCost": 0.00008355,+ "inputUsage": 265,+ "outputUsage": 73,+ "totalUsage": 338,+ "usagePricingTierId": "clyrjpbe20000t0mzcbwc42rg_tier_default",+ "usagePricingTierName": "Standard",+ "metadata": {+ "attributes": {+ "gen_ai.operation.name": "chat",+ "gen_ai.system": "openai",+ "gen_ai.request.model": "gpt-4o-mini",+ "server.address": "api.openai.com",+ "model_request_parameters": {+ "function_tools": [+ {+ "name": "get_pun_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a pun-style joke suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ },+ {+ "name": "get_dad_joke_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a dad joke style suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ },+ {+ "name": "get_one_liner_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a one-liner joke suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ },+ {+ "name": "get_car_joke_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a car-themed joke suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ },+ {+ "name": "get_tree_joke_suggestion",+ "parameters_json_schema": {+ "additionalProperties": false,+ "properties": {+ "topic": {+ "description": "The topic for the joke",+ "type": "string"+ }+ },+ "required": [+ "topic"+ ],+ "type": "object"+ },+ "description": "Get a tree-themed joke suggestion for the given topic.",+ "outer_typed_dict_key": null,+ "strict": true,+ "sequential": false,+ "kind": "function",+ "metadata": null+ }+ ],+ "builtin_tools": [],+ "output_mode": "text",+ "output_object": null,+ "output_tools": [],+ "prompted_output_template": null,+ "allow_text_output": true,+ "allow_image_output": false+ },+ "gen_ai.request.temperature": "0.7",+ "logfire.json_schema": {+ "type": "object",+ "properties": {+ "gen_ai.input.messages": {+ "type": "array"+ },+ "gen_ai.output.messages": {+ "type": "array"+ },+ "model_request_parameters": {+ "type": "object"+ }+ }+ },+ "gen_ai.usage.input_tokens": "265",+ "gen_ai.usage.output_tokens": "73",+ "gen_ai.response.model": "gpt-4o-mini-2024-07-18",+ "operation.cost": "0.00008355",+ "gen_ai.response.id": "chatcmpl-Cj4xu0Nus6lKWVVmxlb7TZTsMizLD",+ "gen_ai.response.finish_reasons": [+ "tool_call"+ ]+ },+ "resourceAttributes": {+ "telemetry.sdk.language": "python",+ "telemetry.sdk.name": "opentelemetry",+ "telemetry.sdk.version": "1.38.0",+ "service.name": "unknown_service"+ },+ "scope": {+ "name": "pydantic-ai",+ "version": "1.26.0",+ "attributes": {}+ }+ },+ "input": [+ {+ "role": "system",+ "parts": [+ {+ "type": "text",+ "content": "You are a creative joke writer. When asked to get inspiration, you will call THREE of the available suggestion tools to gather ideas. When asked to write a joke, create a funny joke based on the suggestions you received."+ }+ ]+ },+ {+ "role": "user",+ "parts": [+ {+ "type": "text",+ "content": "Select and call THREE of the available tools to get joke suggestions about 'programming'."+ }+ ]+ }+ ],+ "output": [+ {+ "role": "assistant",+ "parts": [+ {+ "type": "tool_call",+ "id": "call_X0OSgjUukT5inyEQvuZQnHrk",+ "name": "get_pun_suggestion",+ "arguments": {+ "topic": "programming"+ }+ },+ {+ "type": "tool_call",+ "id": "call_WxZcCvSDhGT4RJHlcU01k10x",+ "name": "get_dad_joke_suggestion",+ "arguments": {+ "topic": "programming"+ }+ },+ {+ "type": "tool_call",+ "id": "call_aRaObiWKKt6GzgDkkUl3bu1Q",+ "name": "get_one_liner_suggestion",+ "arguments": {+ "topic": "programming"+ }+ }+ ],+ "finish_reason": "tool_call"+ }+ ]+ },+ {+ "id": "02d7769b76595f0b",+ "traceId": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "startTime": "2025-12-04T14:51:24.417Z",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "parentObservationId": "93d5543f7340c2e6",+ "type": "TOOL",+ "environment": "default",+ "endTime": "2025-12-04T14:51:24.422Z",+ "name": "running tool: get_dad_joke_suggestion",+ "level": "DEFAULT",+ "statusMessage": null,+ "version": null,+ "createdAt": "2025-12-04T14:51:25.691Z",+ "updatedAt": "2025-12-04T14:51:25.729Z",+ "model": null,+ "internalModelId": null,+ "modelParameters": {},+ "completionStartTime": null,+ "promptId": null,+ "promptName": null,+ "promptVersion": null,+ "latency": 5,+ "timeToFirstToken": null,+ "usageDetails": {},+ "costDetails": {},+ "providedCostDetails": {},+ "inputCost": null,+ "outputCost": null,+ "totalCost": 0,+ "inputUsage": 0,+ "outputUsage": 0,+ "totalUsage": 0,+ "usagePricingTierId": null,+ "usagePricingTierName": null,+ "metadata": {+ "attributes": {+ "gen_ai.tool.name": "get_dad_joke_suggestion",+ "gen_ai.tool.call.id": "call_WxZcCvSDhGT4RJHlcU01k10x",+ "tool_arguments": {+ "topic": "programming"+ },+ "logfire.msg": "running tool: get_dad_joke_suggestion",+ "logfire.json_schema": {+ "type": "object",+ "properties": {+ "tool_arguments": {+ "type": "object"+ },+ "tool_response": {+ "type": "object"+ },+ "gen_ai.tool.name": {},+ "gen_ai.tool.call.id": {}+ }+ },+ "tool_response": "Dad joke idea: Use a classic setup-punchline format about 'programming' with a groan-worthy twist"+ },+ "resourceAttributes": {+ "telemetry.sdk.language": "python",+ "telemetry.sdk.name": "opentelemetry",+ "telemetry.sdk.version": "1.38.0",+ "service.name": "unknown_service"+ },+ "scope": {+ "name": "pydantic-ai",+ "version": "1.26.0",+ "attributes": {}+ }+ },+ "input": {+ "topic": "programming"+ },+ "output": "Dad joke idea: Use a classic setup-punchline format about 'programming' with a groan-worthy twist"+ },+ {+ "id": "199eff9980ea8b99",+ "traceId": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "startTime": "2025-12-04T14:51:24.417Z",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "parentObservationId": "93d5543f7340c2e6",+ "type": "TOOL",+ "environment": "default",+ "endTime": "2025-12-04T14:51:24.422Z",+ "name": "running tool: get_one_liner_suggestion",+ "level": "DEFAULT",+ "statusMessage": null,+ "version": null,+ "createdAt": "2025-12-04T14:51:25.691Z",+ "updatedAt": "2025-12-04T14:51:25.729Z",+ "model": null,+ "internalModelId": null,+ "modelParameters": {},+ "completionStartTime": null,+ "promptId": null,+ "promptName": null,+ "promptVersion": null,+ "latency": 5,+ "timeToFirstToken": null,+ "usageDetails": {},+ "costDetails": {},+ "providedCostDetails": {},+ "inputCost": null,+ "outputCost": null,+ "totalCost": 0,+ "inputUsage": 0,+ "outputUsage": 0,+ "totalUsage": 0,+ "usagePricingTierId": null,+ "usagePricingTierName": null,+ "metadata": {+ "attributes": {+ "gen_ai.tool.name": "get_one_liner_suggestion",+ "gen_ai.tool.call.id": "call_aRaObiWKKt6GzgDkkUl3bu1Q",+ "tool_arguments": {+ "topic": "programming"+ },+ "logfire.msg": "running tool: get_one_liner_suggestion",+ "logfire.json_schema": {+ "type": "object",+ "properties": {+ "tool_arguments": {+ "type": "object"+ },+ "tool_response": {+ "type": "object"+ },+ "gen_ai.tool.name": {},+ "gen_ai.tool.call.id": {}+ }+ },+ "tool_response": "One-liner idea: Make a quick, witty observation about 'programming' in a single sentence"+ },+ "resourceAttributes": {+ "telemetry.sdk.language": "python",+ "telemetry.sdk.name": "opentelemetry",+ "telemetry.sdk.version": "1.38.0",+ "service.name": "unknown_service"+ },+ "scope": {+ "name": "pydantic-ai",+ "version": "1.26.0",+ "attributes": {}+ }+ },+ "input": {+ "topic": "programming"+ },+ "output": "One-liner idea: Make a quick, witty observation about 'programming' in a single sentence"+ },+ {+ "id": "93d5543f7340c2e6",+ "traceId": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "startTime": "2025-12-04T14:51:24.416Z",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "parentObservationId": "5b5c52d029f28206",+ "type": "SPAN",+ "environment": "default",+ "endTime": "2025-12-04T14:51:24.422Z",+ "name": "running 3 tools",+ "level": "DEFAULT",+ "statusMessage": null,+ "version": null,+ "createdAt": "2025-12-04T14:51:25.691Z",+ "updatedAt": "2025-12-04T14:51:25.728Z",+ "model": null,+ "internalModelId": null,+ "modelParameters": null,+ "completionStartTime": null,+ "promptId": null,+ "promptName": null,+ "promptVersion": null,+ "latency": 6,+ "timeToFirstToken": null,+ "usageDetails": {},+ "costDetails": {},+ "providedCostDetails": {},+ "inputCost": null,+ "outputCost": null,+ "totalCost": 0,+ "inputUsage": 0,+ "outputUsage": 0,+ "totalUsage": 0,+ "usagePricingTierId": null,+ "usagePricingTierName": null,+ "metadata": {+ "attributes": {+ "tools": [+ "get_pun_suggestion",+ "get_dad_joke_suggestion",+ "get_one_liner_suggestion"+ ],+ "logfire.msg": "running 3 tools"+ },+ "resourceAttributes": {+ "telemetry.sdk.language": "python",+ "telemetry.sdk.name": "opentelemetry",+ "telemetry.sdk.version": "1.38.0",+ "service.name": "unknown_service"+ },+ "scope": {+ "name": "pydantic-ai",+ "version": "1.26.0",+ "attributes": {}+ }+ },+ "input": null,+ "output": null+ },+ {+ "id": "99ec63d0b5ecdbf5",+ "traceId": "7a38edd8123db47ad8dcb8aa4c5e3926",+ "startTime": "2025-12-04T14:51:24.416Z",+ "projectId": "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a",+ "parentObservationId": "93d5543f7340c2e6",+ "type": "TOOL",+ "environment": "default",+ "endTime": "2025-12-04T14:51:24.422Z",+ "name": "running tool: get_pun_suggestion",+ "level": "DEFAULT",+ "statusMessage": null,+ "version": null,+ "createdAt": "2025-12-04T14:51:25.691Z",+ "updatedAt": "2025-12-04T14:51:25.726Z",+ "model": null,+ "internalModelId": null,+ "modelParameters": {},+ "completionStartTime": null,+ "promptId": null,+ "promptName": null,+ "promptVersion": null,+ "latency": 6,+ "timeToFirstToken": null,+ "usageDetails": {},+ "costDetails": {},+ "providedCostDetails": {},+ "inputCost": null,+ "outputCost": null,+ "totalCost": 0,+ "inputUsage": 0,+ "outputUsage": 0,+ "totalUsage": 0,+ "usagePricingTierId": null,+ "usagePricingTierName": null,+ "metadata": {+ "attributes": {+ "gen_ai.tool.name": "get_pun_suggestion",+ "gen_ai.tool.call.id": "call_X0OSgjUukT5inyEQvuZQnHrk",+ "tool_arguments": {+ "topic": "programming"+ },+ "logfire.msg": "running tool: get_pun_suggestion",+ "logfire.json_schema": {+ "type": "object",+ "properties": {+ "tool_arguments": {+ "type": "object"+ },+ "tool_response": {+ "type": "object"+ },+ "gen_ai.tool.name": {},+ "gen_ai.tool.call.id": {}+ }+ },+ "tool_response": "Pun idea: Play on words related to 'programming' - think about homophones or double meanings"+ },+ "resourceAttributes": {+ "telemetry.sdk.language": "python",+ "telemetry.sdk.name": "opentelemetry",+ "telemetry.sdk.version": "1.38.0",+ "service.name": "unknown_service"+ },+ "scope": {+ "name": "pydantic-ai",+ "version": "1.26.0",+ "attributes": {}+ }+ },+ "input": {+ "topic": "programming"+ },+ "output": "Pun idea: Play on words related to 'programming' - think about homophones or double meanings"+ }+ ]+}\ No newline at end of filediff --git a/packages/shared/scripts/seeder/utils/framework-traces/pydantic-ai-trace-2025-06-06.json b/packages/shared/scripts/seeder/utils/framework-traces/pydantic-ai-trace-2025-06-06.jsondeleted file mode 100644index 17958d1c71..0000000000--- a/packages/shared/scripts/seeder/utils/framework-traces/pydantic-ai-trace-2025-06-06.json+++ /dev/null@@ -1,312 +0,0 @@-{- "trace": {- "id": "25f4bdeebaab60e6e1bee7e8469554bc",- "projectId": "cloramnkj0002jz088vzn1ja4",- "name": "pydantic-ai-qa-trace",- "timestamp": "2025-06-06T14:40:28.562Z",- "environment": "default",- "tags": ["dev", "pydantic-ai"],- "bookmarked": false,- "release": null,- "version": "1.0.0",- "userId": "user_123",- "sessionId": "session_abc",- "public": true,- "input": "\"What is Langfuse?\"",- "output": "\"Langfuse is a tool designed for observability and monitoring of applications that utilize large language models (LLMs). It provides features to trace, log, and visualize requests, helping developers understand the behavior of their LLM-powered applications more effectively. This can be particularly useful for debugging, performance optimization, and ensuring reliable operation of systems that depend on LLMs. Langfuse is designed to integrate easily with existing infrastructure, supporting both self-hosted implementations and cloud-based solutions.\"",- "metadata": "{\"email\":\"[email protected]\",\"resourceAttributes\":{\"telemetry.sdk.language\":\"python\",\"telemetry.sdk.name\":\"opentelemetry\",\"telemetry.sdk.version\":\"1.33.1\",\"service.name\":\"unknown_service\"},\"scope\":{\"name\":\"langfuse-sdk\",\"version\":\"3.0.0\",\"attributes\":{\"public_key\":\"pk-lf-5855d85e-3943-497e-bd10-f50ad414bcba\"}}}",- "createdAt": "2025-06-06T14:40:34.000Z",- "updatedAt": "2025-06-06T14:40:33.635Z",- "latency": 4.795- },- "observations": [- {- "id": "538fed87d11686d3",- "traceId": "25f4bdeebaab60e6e1bee7e8469554bc",- "projectId": "cloramnkj0002jz088vzn1ja4",- "type": "SPAN",- "environment": "default",- "parentObservationId": null,- "startTime": "2025-06-06T14:40:28.562Z",- "endTime": "2025-06-06T14:40:33.357Z",- "name": "pydantic-ai-qa-trace",- "level": "DEFAULT",- "statusMessage": null,- "version": "1.0.0",- "modelParameters": null,- "completionStartTime": null,- "promptId": null,- "createdAt": "2025-06-06T14:40:33.595Z",- "updatedAt": "2025-06-06T14:40:33.630Z",- "usageDetails": {},- "costDetails": {},- "providedCostDetails": {},- "model": null,- "internalModelId": null,- "promptName": null,- "promptVersion": null,- "latency": 4795,- "timeToFirstToken": null,- "inputCost": null,- "outputCost": null,- "totalCost": 0,- "inputUsage": 0,- "outputUsage": 0,- "totalUsage": 0,- "input": null,- "output": null,- "metadata": {- "resourceAttributes": {- "telemetry.sdk.language": "python",- "telemetry.sdk.name": "opentelemetry",- "telemetry.sdk.version": "1.33.1",- "service.name": "unknown_service"- },- "scope": {- "name": "langfuse-sdk",- "version": "3.0.0",- "attributes": {- "public_key": "pk-lf-5855d85e-3943-497e-bd10-f50ad414bcba"- }- }- }- },- {- "id": "0a4fac2553f22f2e",- "traceId": "25f4bdeebaab60e6e1bee7e8469554bc",- "projectId": "cloramnkj0002jz088vzn1ja4",- "type": "SPAN",- "environment": "default",- "parentObservationId": "538fed87d11686d3",- "startTime": "2025-06-06T14:40:28.562Z",- "endTime": "2025-06-06T14:40:33.357Z",- "name": "qa_agent run",- "level": "DEFAULT",- "statusMessage": null,- "version": null,- "modelParameters": null,- "completionStartTime": null,- "promptId": null,- "createdAt": "2025-06-06T14:40:33.596Z",- "updatedAt": "2025-06-06T14:40:33.641Z",- "usageDetails": {},- "costDetails": {},- "providedCostDetails": {},- "model": null,- "internalModelId": null,- "promptName": null,- "promptVersion": null,- "latency": 4795,- "timeToFirstToken": null,- "inputCost": null,- "outputCost": null,- "totalCost": 0,- "inputUsage": 0,- "outputUsage": 0,- "totalUsage": 0,- "input": null,- "output": [- {- "content": "You are a helpful assistant that answers questions clearly and concisely.",- "role": "system",- "gen_ai.message.index": 0,- "event.name": "gen_ai.system.message"- },- {- "content": "What is Langfuse?",- "role": "user",- "gen_ai.message.index": 0,- "event.name": "gen_ai.user.message"- },- {- "role": "assistant",- "content": "Langfuse is a tool designed for observability and monitoring of applications that utilize large language models (LLMs). It provides features to trace, log, and visualize requests, helping developers understand the behavior of their LLM-powered applications more effectively. This can be particularly useful for debugging, performance optimization, and ensuring reliable operation of systems that depend on LLMs. Langfuse is designed to integrate easily with existing infrastructure, supporting both self-hosted implementations and cloud-based solutions.",- "gen_ai.message.index": 1,- "event.name": "gen_ai.assistant.message"- }- ],- "metadata": {- "attributes": {- "model_name": "gpt-4o",- "agent_name": "qa_agent",- "logfire.msg": "qa_agent run",- "final_result": "Langfuse is a tool designed for observability and monitoring of applications that utilize large language models (LLMs). It provides features to trace, log, and visualize requests, helping developers understand the behavior of their LLM-powered applications more effectively. This can be particularly useful for debugging, performance optimization, and ensuring reliable operation of systems that depend on LLMs. Langfuse is designed to integrate easily with existing infrastructure, supporting both self-hosted implementations and cloud-based solutions.",- "gen_ai.usage.input_tokens": "31",- "gen_ai.usage.output_tokens": "96",- "all_messages_events": [- {- "content": "You are a helpful assistant that answers questions clearly and concisely.",- "role": "system",- "gen_ai.message.index": 0,- "event.name": "gen_ai.system.message"- },- {- "content": "What is Langfuse?",- "role": "user",- "gen_ai.message.index": 0,- "event.name": "gen_ai.user.message"- },- {- "role": "assistant",- "content": "Langfuse is a tool designed for observability and monitoring of applications that utilize large language models (LLMs). It provides features to trace, log, and visualize requests, helping developers understand the behavior of their LLM-powered applications more effectively. This can be particularly useful for debugging, performance optimization, and ensuring reliable operation of systems that depend on LLMs. Langfuse is designed to integrate easily with existing infrastructure, supporting both self-hosted implementations and cloud-based solutions.",- "gen_ai.message.index": 1,- "event.name": "gen_ai.assistant.message"- }- ],- "logfire.json_schema": {- "type": "object",- "properties": {- "all_messages_events": {- "type": "array"- },- "final_result": {- "type": "object"- }- }- }- },- "resourceAttributes": {- "telemetry.sdk.language": "python",- "telemetry.sdk.name": "opentelemetry",- "telemetry.sdk.version": "1.33.1",- "service.name": "unknown_service"- },- "scope": {- "name": "pydantic-ai",- "version": "0.2.15",- "attributes": {}- }- }- },- {- "id": "5cb389a3bdd21a6e",- "traceId": "25f4bdeebaab60e6e1bee7e8469554bc",- "projectId": "cloramnkj0002jz088vzn1ja4",- "type": "GENERATION",- "environment": "default",- "parentObservationId": "0a4fac2553f22f2e",- "startTime": "2025-06-06T14:40:28.562Z",- "endTime": "2025-06-06T14:40:33.356Z",- "name": "chat gpt-4o",- "level": "DEFAULT",- "statusMessage": null,- "version": null,- "modelParameters": {},- "completionStartTime": null,- "promptId": null,- "createdAt": "2025-06-06T14:40:33.440Z",- "updatedAt": "2025-06-06T14:40:33.478Z",- "usageDetails": {- "input": 31,- "output": 96,- "total": 127- },- "costDetails": {- "input": 0.0000775,- "output": 0.00096,- "total": 0.0010375- },- "providedCostDetails": {},- "model": "gpt-4o",- "internalModelId": "b9854a5c92dc496b997d99d20",- "promptName": null,- "promptVersion": null,- "latency": 4794,- "timeToFirstToken": null,- "inputCost": 0.0000775,- "outputCost": 0.00096,- "totalCost": 0.0010375,- "inputUsage": 31,- "outputUsage": 96,- "totalUsage": 127,- "input": [- {- "content": "You are a helpful assistant that answers questions clearly and concisely.",- "role": "system",- "gen_ai.system": "openai",- "gen_ai.message.index": 0,- "event.name": "gen_ai.system.message"- },- {- "content": "What is Langfuse?",- "role": "user",- "gen_ai.system": "openai",- "gen_ai.message.index": 0,- "event.name": "gen_ai.user.message"- }- ],- "output": {- "index": 0,- "message": {- "role": "assistant",- "content": "Langfuse is a tool designed for observability and monitoring of applications that utilize large language models (LLMs). It provides features to trace, log, and visualize requests, helping developers understand the behavior of their LLM-powered applications more effectively. This can be particularly useful for debugging, performance optimization, and ensuring reliable operation of systems that depend on LLMs. Langfuse is designed to integrate easily with existing infrastructure, supporting both self-hosted implementations and cloud-based solutions."- },- "gen_ai.system": "openai",- "event.name": "gen_ai.choice"- },- "metadata": {- "attributes": {- "gen_ai.operation.name": "chat",- "gen_ai.system": "openai",- "gen_ai.request.model": "gpt-4o",- "server.address": "api.openai.com",- "model_request_parameters": {- "function_tools": [],- "allow_text_output": true,- "output_tools": []- },- "gen_ai.usage.input_tokens": "31",- "gen_ai.usage.output_tokens": "96",- "gen_ai.response.model": "gpt-4o-2024-08-06",- "events": [- {- "content": "You are a helpful assistant that answers questions clearly and concisely.",- "role": "system",- "gen_ai.system": "openai",- "gen_ai.message.index": 0,- "event.name": "gen_ai.system.message"- },- {- "content": "What is Langfuse?",- "role": "user",- "gen_ai.system": "openai",- "gen_ai.message.index": 0,- "event.name": "gen_ai.user.message"- },- {- "index": 0,- "message": {- "role": "assistant",- "content": "Langfuse is a tool designed for observability and monitoring of applications that utilize large language models (LLMs). It provides features to trace, log, and visualize requests, helping developers understand the behavior of their LLM-powered applications more effectively. This can be particularly useful for debugging, performance optimization, and ensuring reliable operation of systems that depend on LLMs. Langfuse is designed to integrate easily with existing infrastructure, supporting both self-hosted implementations and cloud-based solutions."- },- "gen_ai.system": "openai",- "event.name": "gen_ai.choice"- }- ],- "logfire.json_schema": {- "type": "object",- "properties": {- "events": {- "type": "array"- },- "model_request_parameters": {- "type": "object"- }- }- }- },- "resourceAttributes": {- "telemetry.sdk.language": "python",- "telemetry.sdk.name": "opentelemetry",- "telemetry.sdk.version": "1.33.1",- "service.name": "unknown_service"- },- "scope": {- "name": "pydantic-ai",- "version": "0.2.15",- "attributes": {}- }- }- }- ]-}diff --git a/web/src/utils/chatml/adapters/index.ts b/web/src/utils/chatml/adapters/index.tsindex 093453d69a..81b96b20e7 100644--- a/web/src/utils/chatml/adapters/index.ts+++ b/web/src/utils/chatml/adapters/index.ts@@ -5,6 +5,7 @@ import { aisdkAdapter } from "./aisdk";import { openAIAdapter } from "./openai";import { geminiAdapter } from "./gemini";import { microsoftAgentAdapter } from "./microsoft-agent";+import { pydanticAIAdapter } from "./pydantic-ai";import { genericAdapter } from "./generic";const adapters: ProviderAdapter[] = [@@ -13,6 +14,7 @@ const adapters: ProviderAdapter[] = [openAIAdapter, // OpenAI (Chat Completions & Responses API)geminiAdapter, // Gemini/VertexAI formatmicrosoftAgentAdapter, // Microsoft Agent Framework+ pydanticAIAdapter, // Pydantic AI framework// Add more adapters here as neededgenericAdapter, // Always last (fallback)];diff --git a/web/src/utils/chatml/adapters/pydantic-ai.clienttest.ts b/web/src/utils/chatml/adapters/pydantic-ai.clienttest.tsnew file mode 100644index 0000000000..b1839172d0--- /dev/null+++ b/web/src/utils/chatml/adapters/pydantic-ai.clienttest.ts@@ -0,0 +1,172 @@+jest.mock("@langfuse/shared", () => {+ const { z } = require("zod/v4");++ return {+ ChatMessageRole: {+ System: "system",+ Developer: "developer",+ User: "user",+ Assistant: "assistant",+ Tool: "tool",+ Model: "model",+ },+ BaseChatMlMessageSchema: z+ .object({+ role: z.string().optional(),+ name: z.string().optional(),+ content: z+ .union([+ z.record(z.string(), z.any()),+ z.string(),+ z.array(z.any()),+ z.any(),+ ])+ .nullish(),+ audio: z.any().optional(),+ additional_kwargs: z.record(z.string(), z.any()).optional(),+ tools: z.array(z.any()).optional(),+ tool_calls: z.array(z.any()).optional(),+ tool_call_id: z.string().optional(),+ })+ .passthrough(),+ };+});++import { normalizeInput } from "./index";++describe("Pydantic AI Adapter", () => {+ describe("detection and parsing", () => {+ it("should parse pydantic-ai messages with parts-based tool calls", () => {+ const input = [+ {+ role: "system",+ parts: [+ {+ type: "text",+ content: "You are a creative joke writer.",+ },+ ],+ },+ {+ role: "user",+ parts: [+ {+ type: "text",+ content: "Tell me a joke about programming.",+ },+ ],+ },+ {+ role: "assistant",+ parts: [+ {+ type: "tool_call",+ id: "call_123",+ name: "get_pun_suggestion",+ arguments: {+ topic: "programming",+ },+ },+ ],+ finish_reason: "tool_call",+ },+ {+ role: "user",+ parts: [+ {+ type: "tool_call_response",+ id: "call_123",+ name: "get_pun_suggestion",+ result:+ "Pun idea: Play on words related to 'programming' - think about homophones or double meanings",+ },+ ],+ },+ ];++ const result = normalizeInput(input, {+ metadata: {+ scope: {+ name: "pydantic-ai",+ version: "1.26.0",+ },+ attributes: {+ model_request_parameters: {+ function_tools: [+ {+ name: "get_pun_suggestion",+ description: "Get a pun-style joke suggestion",+ parameters_json_schema: {+ type: "object",+ properties: {+ topic: { type: "string" },+ },+ required: ["topic"],+ },+ },+ {+ name: "get_dad_joke_suggestion",+ description: "Get a dad joke suggestion",+ parameters_json_schema: {+ type: "object",+ properties: {+ topic: { type: "string" },+ },+ required: ["topic"],+ },+ },+ ],+ },+ },+ },+ });++ expect(result.success).toBe(true);+ expect(result.data).toHaveLength(4); // system, user, assistant, tool response++ // First message - system+ expect(result.data?.[0].role).toBe("system");+ expect(result.data?.[0].content).toBe("You are a creative joke writer.");++ // Check AVAILABLE tools are attached to messages+ expect(result.data?.[0].tools).toHaveLength(2);+ expect(result.data?.[0].tools?.[0]).toEqual({+ name: "get_pun_suggestion",+ description: "Get a pun-style joke suggestion",+ parameters: {+ type: "object",+ properties: {+ topic: { type: "string" },+ },+ required: ["topic"],+ },+ });++ // Second message - user+ expect(result.data?.[1].role).toBe("user");+ expect(result.data?.[1].content).toBe(+ "Tell me a joke about programming.",+ );+ expect(result.data?.[1].tools).toHaveLength(2); // Available tools attached++ // Third message - assistant with CALLED tool+ expect(result.data?.[2].role).toBe("assistant");+ expect(result.data?.[2].tools).toHaveLength(2); // 2 tools available++ // But only 1 tool was called+ expect(result.data?.[2].tool_calls).toHaveLength(1);+ expect(result.data?.[2].tool_calls?.[0]).toEqual({+ id: "call_123",+ name: "get_pun_suggestion",+ arguments: '{"topic":"programming"}',+ type: "function",+ });++ // Fourth message - tool response+ expect(result.data?.[3].role).toBe("tool");+ expect(result.data?.[3].tool_call_id).toBe("call_123");+ expect(result.data?.[3].content).toContain("Pun idea");+ expect(result.data?.[3].tools).toHaveLength(2); // Available tools attached+ });+ });+});diff --git a/web/src/utils/chatml/adapters/pydantic-ai.ts b/web/src/utils/chatml/adapters/pydantic-ai.tsnew file mode 100644index 0000000000..9db49e6453--- /dev/null+++ b/web/src/utils/chatml/adapters/pydantic-ai.ts@@ -0,0 +1,227 @@+import type { NormalizerContext, ProviderAdapter } from "../types";+import { removeNullFields, parseMetadata, getNestedProperty } from "../helpers";+import { z } from "zod/v4";++/**+ * Pydantic AI adapter+ * Handles pydantic-ai's parts-based message format+ *+ * Pydantic AI uses parts arrays:+ * - Text: {type: "text", content: "..."}+ * - Tool calls: {type: "tool_call", id, name, arguments}+ * - Tool responses: {type: "tool_call_response", id, name, result}+ * Tools are in: metadata.attributes.model_request_parameters.function_tools+ */++// Detection schema+const PydanticAIMessagesSchema = z.array(+ z.looseObject({+ role: z.enum(["system", "user", "assistant"]),+ parts: z.array(z.any()),+ }),+);++/**+ * Extract tool calls, text, and tool responses from parts array+ */+function extractFromParts(parts: unknown[]): {+ toolCalls: Array<Record<string, unknown>>;+ toolResponses: Array<Record<string, unknown>>;+ text: string;+} {+ const toolCalls: Array<Record<string, unknown>> = [];+ const toolResponses: Array<Record<string, unknown>> = [];+ const textParts: string[] = [];++ for (const part of parts) {+ if (!part || typeof part !== "object") continue;+ const p = part as Record<string, unknown>;++ if (p.type === "text" && typeof p.content === "string") {+ textParts.push(p.content);+ } else if (p.type === "tool_call") {+ toolCalls.push({+ id: p.id,+ name: p.name,+ arguments:+ typeof p.arguments === "string"+ ? p.arguments+ : JSON.stringify(p.arguments ?? {}),+ type: "function",+ });+ } else if (p.type === "tool_call_response") {+ toolResponses.push({+ tool_call_id: p.id,+ content:+ typeof p.result === "string"+ ? p.result+ : JSON.stringify(p.result ?? ""),+ });+ }+ }++ return { toolCalls, toolResponses, text: textParts.join("") };+}++/**+ * Normalize pydantic-ai tool definition to standard format+ */+function normalizeToolDefinition(tool: unknown): Record<string, unknown> {+ if (!tool || typeof tool !== "object") return {};++ const t = tool as Record<string, unknown>;+ const normalized: Record<string, unknown> = {+ name: t.name,+ description: t.description || "",+ };++ // pydantic-ai uses parameters_json_schema instead of parameters+ if (t.parameters_json_schema) {+ normalized.parameters = t.parameters_json_schema;+ }++ return normalized;+}++/**+ * Extract tool definitions from pydantic-ai metadata+ * Tools are in: metadata.attributes.model_request_parameters.function_tools+ */+function extractToolDefinitions(+ metadata: unknown,+): Array<Record<string, unknown>> {+ const meta = parseMetadata(metadata);+ if (!meta) return [];++ const tools = getNestedProperty(+ meta,+ "attributes",+ "model_request_parameters",+ "function_tools",+ );++ if (Array.isArray(tools)) {+ return tools.map(normalizeToolDefinition);+ }++ return [];+}++/**+ * Normalize a single pydantic-ai message+ * Returns either a single message or array of messages (for tool responses)+ */+function normalizeMessage(+ msg: unknown,+): Record<string, unknown> | Record<string, unknown>[] {+ if (!msg || typeof msg !== "object") return {};++ const message = msg as Record<string, unknown>;++ // If no parts, return as-is+ if (!Array.isArray(message.parts)) {+ return removeNullFields(message);+ }++ const { toolCalls, toolResponses, text } = extractFromParts(message.parts);++ // Extract other fields (exclude role and parts)+ const { role: _role, parts: _parts, ...rest } = message;++ // Assistant message with tool calls+ if (message.role === "assistant" && toolCalls.length > 0) {+ return removeNullFields({+ role: "assistant",+ content: text || "",+ tool_calls: toolCalls,+ ...rest,+ });+ }++ // User message with tool responses - split into separate tool messages+ if (message.role === "user" && toolResponses.length > 0) {+ return toolResponses.map((tr) =>+ removeNullFields({+ role: "tool",+ ...tr,+ }),+ );+ }++ // Regular text message+ return removeNullFields({+ role: message.role,+ content: text || "",+ ...rest,+ });+}++function normalizeMessages(data: unknown[]): unknown[] {+ return data.flatMap((msg) => {+ const normalized = normalizeMessage(msg);+ return Array.isArray(normalized) ? normalized : [normalized];+ });+}++function preprocessData(data: unknown, ctx: NormalizerContext): unknown {+ if (!data) return data;++ // Handle array of messages+ if (Array.isArray(data)) {+ const normalized = normalizeMessages(data);++ // Extract and attach tool definitions from metadata+ const tools = extractToolDefinitions(ctx.metadata);+ if (tools.length > 0) {+ return normalized.map((msg) => ({+ ...(msg as Record<string, unknown>),+ tools,+ }));+ }++ return normalized;+ }++ // messages wrapper+ if (typeof data === "object" && "messages" in data) {+ const obj = data as Record<string, unknown>;+ return {+ ...obj,+ messages: Array.isArray(obj.messages)+ ? normalizeMessages(obj.messages)+ : obj.messages,+ };+ }++ // Single message+ return normalizeMessage(data);+}++export const pydanticAIAdapter: ProviderAdapter = {+ id: "pydantic-ai",++ detect(ctx: NormalizerContext): boolean {+ const meta = parseMetadata(ctx.metadata);++ if (ctx.framework === "pydantic-ai") return true;++ const scopeName = getNestedProperty(meta, "scope", "name");+ if (scopeName === "pydantic-ai") return true;++ // STRUCTURAL: Schema-based detection on metadata (check metadata first for performance)+ if (PydanticAIMessagesSchema.safeParse(ctx.metadata).success) return true;++ // Schema-based detection on data (slower, do last)+ if (PydanticAIMessagesSchema.safeParse(ctx.data).success) return true;++ return false;+ },++ preprocess(+ data: unknown,+ _kind: "input" | "output",+ ctx: NormalizerContext,+ ): unknown {+ return preprocessData(data, ctx);+ },+};