# detect_mode_prefix

> **Function** in `deepagents_code`

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

Return the longest mode prefix and mode for `text`, if any.

Longer prefixes win so multi-character triggers like `!!` are matched
before their single-character prefixes (`!`).

## Signature

```python
detect_mode_prefix(
    text: str,
) -> tuple[str, str] | None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `text` | `str` | Yes | Input text that may start with a mode trigger. |

## Returns

`tuple[str, str] | None`

Tuple of `(prefix, mode)` for the longest matching trigger, otherwise

---

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