# truncate_if_too_long

> **Function** in `deepagents`

📖 [View in docs](https://reference.langchain.com/python/deepagents/backends/utils/truncate_if_too_long)

Truncate list or string result if it exceeds token limit (rough estimate: 4 chars/token).

## Signature

```python
truncate_if_too_long(
    result: list[str] | str,
) -> list[str] | str
```

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/a9e6e4f7ad7fe161dd9affc3d74bb19784aca70b/libs/deepagents/deepagents/backends/utils.py#L375)