Messages
The Messages tab of a trace shows its trace messages: the system, user, assistant, and tool messages its LLM calls received and returned, each listed once. Messages contain text, tool calls and results, reasoning, and files. Evaluators that run on a whole trace read the same messages.
![]()
Messages are organized in threads, each a single sequence of messages. Most traces have one thread. Traces with sub-agents, guardrails, or parallel LLM calls can have several; see multi-threaded applications.
How messages are built
Only generation observations create messages. tool observations attach their result to the matching tool call.
Most applications resend the earlier messages with every LLM call. Langfuse shows each message once: from each generation's input, it adds only the messages not shown yet, then it adds the generation's output.
Generation 1 input: User: Refund order 123.
output: Assistant: [calls refund_order]
Tool output: Refund succeeded.
Generation 2 input: User: Refund order 123.
Assistant: [calls refund_order]
Tool: Refund succeeded.
output: Assistant: Your refund is on its way.
Messages: User: Refund order 123.
Assistant: [calls refund_order]
Tool: Refund succeeded.
Assistant: Your refund is on its way.A message that repeats on purpose, such as a user writing "Thanks" twice, stays. A system prompt that stays the same shows only once, and a changed system prompt shows as a new system message.
Supported message formats
Langfuse reads messages from generation input and output in these formats. The Formatted view of an observation's input and output uses the same formats.
| Format | Covers |
|---|---|
| OpenAI | Chat Completions and Responses APIs, and OpenAI-compatible APIs |
| Anthropic | Messages API |
| Gemini and Vertex AI | |
| LangChain | LangChain and LangGraph messages |
| Vercel AI SDK | AI SDK prompts and responses |
| OpenTelemetry GenAI | GenAI semantic conventions, including Microsoft Agent Framework spans |
| Pydantic AI | Pydantic AI message history |
| Semantic Kernel | Semantic Kernel GenAI events |
| agno and koog | Agno and koog agent messages |
| Langfuse agent plugins | Messages from Langfuse plugins for coding agents |
Providers without their own format, such as Amazon Bedrock, Mistral, and Cohere, are read by generic detection.
Langfuse detects formats by the shape of the payload, not by a provider label, so payloads that mix formats still work. The first format that recognizes the messages reads them. If none does, a string becomes a text message, and other values are kept as structured data.
Normalized messages
Every format becomes the same list of messages, each with a role and a list of parts. For example, this generation in the OpenAI format:
{
"input": [{ "role": "user", "content": "What is 2 + 2?" }],
"output": { "role": "assistant", "content": "4" }
}becomes:
[
{ "role": "user", "parts": [{ "type": "text", "text": "What is 2 + 2?" }] },
{ "role": "assistant", "parts": [{ "type": "text", "text": "4" }] }
]Roles are system, user, assistant, or tool. Part types are text, reasoning, tool-call, tool-result, and file, with data and custom for content no format maps.
OpenTelemetry attributes
During OpenTelemetry ingestion, Langfuse maps common message attributes to the observation's input and output, for example:
langfuse.observation.inputandlangfuse.observation.output, which take precedence over all othersgen_ai.input.messagesandgen_ai.output.messagesgen_ai.prompt.*andgen_ai.completion.*llm.input_messages.*andllm.output_messages.*ai.prompt.messagesfrom the Vercel AI SDK
See attribute mapping for the other observation attributes.
Multi-threaded applications
A trace has several threads when its LLM calls don't share message history, for example a guardrail check, sub-agents, or parallel calls.
![]()
These rules decide which thread a generation joins and which threads you see:
- A generation continues the newest thread whose messages its input repeats. Otherwise, it starts a new thread. A generation whose input drops earlier messages, for example after context compaction, also starts a new thread.
- The Messages tab shows the threads at the shallowest nesting level of the trace tree. Deeper threads, such as a sub-agent's, are behind N nested threads hidden. Click Show to see them.
- Threads are ordered by when they started and numbered 1.1, 1.2, and so on. The numbers count only the visible threads. Evaluators read all threads in that order, including nested ones, so the first thread can be a guardrail or sub-agent rather than the main agent's thread.
No messages
If the Messages tab is empty or incomplete, or trace evaluations skip a trace, check these causes. See Why does my trace have no messages? for details.
| Cause | Fix |
|---|---|
No generation observations | Log each LLM call as a generation |
| Generation input and output are empty | Set them on the generation, not on a parent span |
| More than 1,000 generation and tool observations, or messages over 1 million characters in total | Split the work into smaller traces |
GitHub Discussions
Last updated on