# serialize_hook_input

> **Function** in `deepagents_code`

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

Serialize a hook invocation as validated compatible JSON.

## Signature

```python
serialize_hook_input(
    invocation: HookInvocation,
    *,
    transcript_path: Path,
    agent_transcript_path: Path | None = None,
) -> bytes
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `invocation` | `HookInvocation` | Yes | Native lifecycle invocation. |
| `transcript_path` | `Path` | Yes | Materialized client transcript path. |
| `agent_transcript_path` | `Path \| None` | No | Materialized subagent transcript path. (default: `None`) |

## Returns

`bytes`

Compact JSON bytes suitable for command stdin.

---

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