---
title: Messages
description: Read a trace's LLM calls as trace messages, with repeated history removed. Learn how messages and threads are built, which message formats Langfuse reads, and why a trace can have no messages.
sidebarTitle: Messages
---

# 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 tab of a trace showing a collapsed system prompt, the user's question, reasoning, three tool calls, and the assistant's answer with a table](/images/docs/observability/messages-view-single-thread.png)

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](#multi-threaded).

## How messages are built [#assembly]

Only `generation` [observations](/docs/observability/features/observation-types) 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.

```text
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 [#supported-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                                                          |
| Google                 | 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 [#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:

```json
{
  "input": [{ "role": "user", "content": "What is 2 + 2?" }],
  "output": { "role": "assistant", "content": "4" }
}
```

becomes:

```json
[
  { "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 [#otel-attributes]

During OpenTelemetry ingestion, Langfuse maps common message attributes to the observation's input and output, for example:

- `langfuse.observation.input` and `langfuse.observation.output`, which take precedence over all others
- `gen_ai.input.messages` and `gen_ai.output.messages`
- `gen_ai.prompt.*` and `gen_ai.completion.*`
- `llm.input_messages.*` and `llm.output_messages.*`
- `ai.prompt.messages` from the Vercel AI SDK

See [attribute mapping](/integrations/native/opentelemetry#observation-level-attributes) for the other observation attributes.

## Multi-threaded applications [#multi-threaded]

A trace has several threads when its LLM calls don't share message history, for example a guardrail check, sub-agents, or parallel calls.

  ![Messages of a trip-planner trace with three labeled threads: 1.1 is a guardrail call, 1.2 is the main agent, and an arrow points from 1.2 to 1.3, the nested sub-agent it spawned. Nested threads such as 1.3 are hidden behind Show by default.](/images/docs/observability/messages-view-multi-thread.png)

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 [#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?](/faq/all/trace-has-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](/faq/all/trace-has-no-messages#stay-within-the-size-limits) |

## GitHub Discussions

<!-- agent-instructions -->

---

## Agent Instructions

This page is part of the [Langfuse](https://langfuse.com) documentation, published as plain Markdown for AI agents. Every page is available as Markdown by appending `.md` to its URL, or by sending an `Accept: text/markdown` header. This page: `https://langfuse.com/docs/observability/features/messages.md`.

### Querying these docs

If the answer is not on this page, query the documentation instead of guessing:

- **Semantic search** across all Langfuse docs, returning an answer with the relevant pages and excerpts. Ask a specific, self-contained question:

  ```bash
  curl -sG "https://langfuse.com/api/search-docs" --data-urlencode "query=How do I trace a LangGraph agent?"
  ```

- **Index of every page**: <https://langfuse.com/llms.txt>, with per-section indexes [llms-docs.txt](https://langfuse.com/llms-docs.txt), [llms-integrations.txt](https://langfuse.com/llms-integrations.txt), and [llms-self-hosting.txt](https://langfuse.com/llms-self-hosting.txt).

### Before writing Langfuse code

- **Install the [Langfuse Agent Skill](https://langfuse.com/docs/api-and-data-platform/features/agent-skill).** It encodes Langfuse's own best practices for instrumentation, prompt management, and evaluation, and materially improves results.
- **Read [What does a good trace look like?](https://langfuse.com/docs/observability/best-practices.md)** before instrumenting an application.
- **Verify endpoints, parameters, and response fields** against the [OpenAPI spec](https://cloud.langfuse.com/generated/api/openapi.yml), or read the [API reference as Markdown](https://api.reference.langfuse.com/index.md), instead of inferring them from code examples.
- **Use the [Langfuse CLI](https://langfuse.com/docs/api-and-data-platform/features/cli)** (`npx @langfuse/cli api <resource> <action>`) to read or write traces, prompts, datasets, and scores from the terminal.

Found an error in these docs? Please open an issue at <https://github.com/langfuse/langfuse-docs/issues>.
