> ## Documentation Index
> Fetch the complete documentation index at: https://braintrust.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Thread view span extraction and filtering

export const plans_0 = "Any"

export const deployments_0 = "Any"

export const data_plane_version_0 = undefined

export const use_case_0 = undefined

<Note>
  **Applies to:**

  * Plan - {plans_0}
  * Deployment - {deployments_0}
  * {data_plane_version_0}
  * {use_case_0}
</Note>

## Summary

**Goal:** Understand which spans appear in the trace Thread view and how the preprocessor selection affects extraction.

## Thread view preprocessor modes

The Thread tab's preprocessor picker controls how spans become a conversation:

* **Default**: The Thread view walks the trace and shows the root span, LLM-typed spans, and facet-typed spans inline. Score-typed spans render in a separate block. No preprocessor function runs and no cross-span deduplication happens.
* **Thread**: The built-in Thread preprocessor runs across every non-scorer span in the trace, extracts messages from `input` and `output`, and deduplicates across spans. This is the same preprocessor [Topics uses by default](/observe/topics/enable).
* **Custom preprocessor**: A saved JavaScript function runs on each span and returns the message array the Thread view renders. See [Write a custom preprocessor](/observe/topics/enable#write-a-custom-preprocessor).

## Span type attribution (Default mode)

To make a span appear in **Default** mode, set `span_attributes.type` to `"llm"` or `"facet"`:

```python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import braintrust

with braintrust.start_span(span_attributes={"type": "llm"}):
    result = client.chat.completions.create(...)
```

Score-typed spans (`type="score"`) render in a separate scorer block, not inline with the conversation.

## Format requirements

Both modes extract messages from each span's `input` and `output`. The fields must match a recognized shape: OpenAI-style role/content arrays, single message objects, content-parts arrays, plain strings, provider payloads (OpenAI, Anthropic, Google Gemini, Bedrock), framework formats (Vercel AI SDK, Pydantic AI, LangChain), or one of the wrapper keys `messages`, `prompt`, `input`, `output`, `choices`, `result`, `response`. For the full list and how to adapt traces that don't render, see [When traces don't work](/observe/topics/enable#when-traces-dont-work).

## Custom trace views

For span selection beyond what preprocessors can do, build a [custom trace view](/annotate/custom-views). Custom views receive the full trace JSON and can extract fields from any span.
