# merge_managed_over_user

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/configuration/service/merge_managed_over_user)

Merge managed policy over user config with this project's precedence.

The single statement of managed-over-user precedence. It was assembled by
hand at three call sites, two carrying "must match" comments, and had
already drifted once: the site that omitted the validator reported a user
table as effective while its provenance credited managed policy.

## Signature

```python
merge_managed_over_user(
    user: Mapping[str, Any],
    managed: Mapping[str, Any],
    *,
    prefix: tuple[str, ...] = (),
) -> tuple[dict[str, Any], dict[str, str]]
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `user` | `Mapping[str, Any]` | Yes | Lower-precedence user table. |
| `managed` | `Mapping[str, Any]` | Yes | Higher-precedence managed table, whose leaves win. |
| `prefix` | `tuple[str, ...]` | No | Absolute manifest path of the subtree being merged. The union set and the validator both match paths relative to where the merge starts, so a subtree merge needs them rebased: an absolute deny-list path never matches inside a subtree, and an unprefixed leaf path resolves to no manifest option, which makes the validator accept everything. (default: `()`) |

## Returns

`tuple[dict[str, Any], dict[str, str]]`

Merged table and dotted leaf-to-source mapping.

---

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