# strip_media_placeholders

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/media_utils/strip_media_placeholders)

Remove display-only media placeholders from user text.

Placeholders like `[image 1]` are inserted into the terminal input purely for
display; the actual media travels as structured content blocks. They must not
leak into the canonical model-facing message or LangSmith trace as if the user
typed them.

When available, tracked placeholder spans identify the exact display tokens to
strip so user-authored literal duplicates with the same token are preserved.
The token fallback removes one matching occurrence per tracked media item for
callers that only have placeholder text.

## Signature

```python
strip_media_placeholders(
    text: str,
    placeholders: Iterable[str],
    *,
    placeholder_spans: Iterable[tuple[int, int]] | None = None,
) -> str
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `text` | `str` | Yes | Raw user text that may contain media placeholders. |
| `placeholders` | `Iterable[str]` | Yes | Exact placeholder tokens for the media actually attached to this message (e.g. ``["[image 1]", "[video 1]"]``). |
| `placeholder_spans` | `Iterable[tuple[int, int]] \| None` | No | Exact `(start, end)` spans for tracked display tokens in `text`, when known. (default: `None`) |

## Returns

`str`

Text with the given media placeholders removed and surrounding whitespace

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/7794b61a6e76230e8c7a49bdce808b3728305914/libs/code/deepagents_code/media_utils.py#L56)