# EmptyTruncatedReplyMiddleware

> **Class** in `deepagents_code`

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

Fail the main run when the provider cut off a reply before any output.

Without this, a reply with no text, no tool calls, and a truncation stop
reason ends the run as a success. The empty message is checkpointed and
the UI shows nothing, so the app looks hung. Raising instead fails the
model node, so the empty message is not saved and the client shows the
error. A partial reply is left alone; the client warns about it.

This middleware never retries. It must wrap the retry middleware, so the
error is not retried, and any recovery middleware that may still repair
the reply.

## Signature

```python
EmptyTruncatedReplyMiddleware()
```

## Extends

- `AgentMiddleware`

## Properties

- `trace_policy`

## Methods

- [`wrap_tool_call()`](https://reference.langchain.com/python/deepagents-code/output_truncation/EmptyTruncatedReplyMiddleware/wrap_tool_call)
- [`awrap_tool_call()`](https://reference.langchain.com/python/deepagents-code/output_truncation/EmptyTruncatedReplyMiddleware/awrap_tool_call)
- [`wrap_model_call()`](https://reference.langchain.com/python/deepagents-code/output_truncation/EmptyTruncatedReplyMiddleware/wrap_model_call)
- [`awrap_model_call()`](https://reference.langchain.com/python/deepagents-code/output_truncation/EmptyTruncatedReplyMiddleware/awrap_model_call)

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/efa9f5364b83e9367ea57d9c21b15b4d81fdcb7a/libs/code/deepagents_code/output_truncation.py#L287)