# display_caveat

> **Function** in `deepagents_code`

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

Return what a successful file operation could not show, if anything.

Every case here leaves the caveat as the user's only account of a change the
transcript cannot render, so each has to name what is missing. Silence would
read as a complete report.

Covers all of `DiffOutcome` rather than the subset that mounts a diff: a
`delete` whose pre-image was lost produces no diff at all, so a caveat routed
only through the diff would leave destroying a 5,000-line file rendering
exactly like destroying an empty one.

Lives here rather than on any one surface because three need it: the tool
row, the `DiffMessage` that may replace it, and `non_interactive`'s printed
output. A caveat produced in only one place is a caveat that goes missing on
whichever surface the user happens to be using — which is how `-p` came to
print an unqualified path for a change it could not verify.

Keyed on the outcome rather than on a `FileOperationRecord` so a widget
holding only the outcome produces the identical sentence, and the wording
cannot drift between surfaces. That holds for every outcome whose text is
self-contained; `unreadable_after` is the exception, degrading to a generic
reason without `after_read_error`. No current caller reaches it — that path
leaves `record.diff` unset, so no `DiffMessage` mounts — but a future one
passing only the outcome would render a weaker sentence than the tool row.

## Signature

```python
display_caveat(
    outcome: DiffOutcome,
    tool_name: str,
    after_read_error: str | None = None,
) -> str
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `outcome` | `DiffOutcome` | Yes | What the operation can honestly say about what it changed. |
| `tool_name` | `str` | Yes | Name of the tool that ran, quoted into the sentence. |
| `after_read_error` | `str \| None` | No | Reason the post-operation read failed. Required in substance for `unreadable_after`, where it is the only part of the sentence that says anything actionable. (default: `None`) |

## Returns

`str`

A caveat to show alongside the tool's own output, or empty when the

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/2069079e09546060f5b52b2cd4f0e3c813e820f3/libs/code/deepagents_code/file_ops.py#L49)