# migrate_legacy_hooks

> **Function** in `deepagents_code`

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

Convert legacy dotted-event hook entries into Hooks v2 configuration.

Each distinct legacy event name becomes its own matcher group so a single
entry subscribed to both `session.start` and `user.prompt` still runs once
per mapped name with the matching reconstructed stdin payload.

## Signature

```python
migrate_legacy_hooks(
    legacy_hooks: Sequence[Mapping[str, object]],
) -> HooksConfig
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `legacy_hooks` | `Sequence[Mapping[str, object]]` | Yes | Entries from the legacy `hooks.json` list form. |

## Returns

`HooksConfig`

A validated Hooks v2 configuration containing only migratable events.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/caaa7e7c12d214afa5cf0a1afed8eb6232aa6f7b/libs/code/deepagents_code/hooks/migration.py#L52)