You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pydantic AI agents behind LiteLLM, traced into Langfuse v4 over OTel. One agent run is one agent observation with N generation children, where N is the tool-call loop depth and varies per input. Same shape in the OpenAI Agents SDK, LangGraph, and anything else that round-trips tools.
Problem
Prompt links live on generation observations only, as do model, usage, and cost. A single agent run driven by a single prompt version therefore records N linked generations.
What that breaks:
Instantiation count measures steps, not runs. The Metrics tab reports N per run. A prompt version that solves the task in fewer tool calls looks like it was used less and costs less per generation, while it may cost more per run. The two metrics move in opposite directions.
Per-run cost and latency aren't available natively. "What does v7 cost per run, and how long does it take end to end?" needs a Metrics API export re-aggregated by trace outside Langfuse.
Run-level scores can't be joined to prompt versions. Task success or a judge on the final answer attaches to the trace or the agent observation. The prompt link sits on the children. There is no native path from prompt version to run-level score.
Model linking has the same gap. With LiteLLM routing steps across models, a run has no single model, and nowhere to record the routing policy that governed it.
Workarounds and where they stop
propagate_attributes / trace metadata carrying prompt_name and prompt_version: filterable, but no native Prompt → Metrics linkage and no version comparison in the UI.
SpanProcessor stamping langfuse.prompt.* on every generation in the run (the documented OpenAI Agents SDK pattern): gives linkage, and bakes in the count inflation.
Wrapping the agent in a generation: produces an empty-IO generation above the real ones, distorts the tree, and double-counts cost if usage is set on it.
Proposal
Accept prompt on span-based observation types, agent at minimum, through the SDKs and through the langfuse.prompt.name / langfuse.prompt.version OTel attributes.
Define the aggregation for a prompt linked to an agent observation:
count: one instantiation per agent observation
cost, tokens: summed over the observation subtree
latency: duration of the agent observation
scope: descendants carrying their own prompt link are excluded from the parent's roll-up and attributed to their own prompt
Add a unit-of-aggregation toggle on the prompt Metrics tab, generation or agent run, with the current generation behaviour as default.
Allow a model or routing-policy string on agent observations, so routed runs record what policy was in force.
Additional information
I do note discussion 6859, but that is at trace level which doesn't make sense, the above seems achievable and gives flexibility at the correct grain for agentic workflows
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Describe the feature or potential improvement
Setup
Pydantic AI agents behind LiteLLM, traced into Langfuse v4 over OTel. One agent run is one agent observation with N generation children, where N is the tool-call loop depth and varies per input. Same shape in the OpenAI Agents SDK, LangGraph, and anything else that round-trips tools.
Problem
Prompt links live on generation observations only, as do model, usage, and cost. A single agent run driven by a single prompt version therefore records N linked generations.
What that breaks:
Workarounds and where they stop
Proposal
Additional information
I do note discussion 6859, but that is at trace level which doesn't make sense, the above seems achievable and gives flexibility at the correct grain for agentic workflows
All reactions