# CachingRuleProcessor

> **Class** in `deepagents_code`

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

Apply secret rules per string and remember the result in a bounded LRU.

The output for a string is the same whether it comes from the cache or
from the rules, so the cache cannot let a secret through. Strings too large
for the character budget are masked each time and not cached.

## Signature

```python
CachingRuleProcessor(
    self,
    rules: list[StringNodeRule],
    *,
    max_entries: int = _MAX_ENTRIES,
    max_chars: int = _MAX_CHARS,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `rules` | `list[StringNodeRule]` | Yes | Redaction rules, applied in order to every string. |
| `max_entries` | `int` | No | Upper bound on cached strings. (default: `_MAX_ENTRIES`) |
| `max_chars` | `int` | No | Upper bound on characters the cache holds. (default: `_MAX_CHARS`) |

## Extends

- `StringNodeProcessor`

## Constructors

```python
__init__(
    self,
    rules: list[StringNodeRule],
    *,
    max_entries: int = _MAX_ENTRIES,
    max_chars: int = _MAX_CHARS,
) -> None
```

| Name | Type |
|------|------|
| `rules` | `list[StringNodeRule]` |
| `max_entries` | `int` |
| `max_chars` | `int` |


## Methods

- [`mask_nodes()`](https://reference.langchain.com/python/deepagents-code/_trace_redaction/CachingRuleProcessor/mask_nodes)

---

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