# validate_terminal_sequence

> **Function** in `deepagents_code`

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

Return `value` when it is composed only of allowlisted sequences.

Allowed tokens are OSC `0`/`1`/`2`/`9`/`99`/`777` (BEL or ST terminated)
and bare BEL. Any other escape or control content rejects the entire value.

## Signature

```python
validate_terminal_sequence(
    value: str,
) -> str | None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `value` | `str` | Yes | Candidate `terminalSequence` payload. |

## Returns

`str | None`

The original string when valid, otherwise `None`.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/4bfa52000ef65ac623d8ada0cb67f67cbdd663ea/libs/code/deepagents_code/hooks/validate_terminal_sequence.py#L16)