# StateFileSearchMiddleware

> **Class** in `langchain_anthropic`

📖 [View in docs](https://reference.langchain.com/python/langchain-anthropic/middleware/file_search/StateFileSearchMiddleware)

Provides Glob and Grep search over state-based files.

This middleware adds two tools that search through virtual files in state:

- Glob: Fast file pattern matching by file path
- Grep: Fast content search using regular expressions

## Signature

```python
StateFileSearchMiddleware(
    self,
    *,
    state_key: str = 'text_editor_files',
)
```

## Description

**Example:**

```python
from langchain.agents import create_agent
from langchain.agents.middleware import (
    StateTextEditorToolMiddleware,
    StateFileSearchMiddleware,
)

agent = create_agent(
    model=model,
    tools=[],
    middleware=[
        StateTextEditorToolMiddleware(),
        StateFileSearchMiddleware(),
    ],
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `state_key` | `str` | No | State key to search  Use `'memory_files'` to search memory tool files. (default: `'text_editor_files'`) |

## Extends

- `AgentMiddleware`

## Constructors

```python
__init__(
    self,
    *,
    state_key: str = 'text_editor_files',
) -> None
```

| Name | Type |
|------|------|
| `state_key` | `str` |


## Properties

- `state_schema`
- `state_key`
- `glob_search`
- `grep_search`
- `tools`

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/fb6ab993a73180538f6cca876b3c85d46c08845f/libs/partners/anthropic/langchain_anthropic/middleware/file_search.py#L87)