# create_cached_secret_anonymizer

> **Function** in `deepagents_code`

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

Build a secret anonymizer that matches `create_secret_anonymizer`.

It uses the same default rules and depth, and adds a per-string cache so
unchanged history strings are not scanned again on each traced run.

## Signature

```python
create_cached_secret_anonymizer() -> Callable[[Any], Any]
```

## Returns

`Callable[[Any], Any]`

An anonymizer to pass to `langsmith.Client(anonymizer=...)`.

---

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