# set_thread_metadata

> **Function** in `deepagents_code`

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

Persist discovery and resume metadata on a newly checkpointed thread.

The remote state-update API does not forward config metadata. Stamp the
saved checkpoints before exposing a newly seeded thread to the user.

## Signature

```python
set_thread_metadata(
    thread_id: str,
    *,
    agent_name: str,
    cwd: str,
) -> None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `thread_id` | `str` | Yes | Newly seeded thread identifier. |
| `agent_name` | `str` | Yes | Agent that owns the new thread. |
| `cwd` | `str` | Yes | Workspace directory used for thread discovery. |

---

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