Files
docs/build/snippets/python/code-samples/customization-middleware-do-py.mdx
T
2026-07-29 10:28:19 +00:00

12 lines
269 B
Plaintext

```python
from langchain.agents.middleware import AgentMiddleware
class CustomMiddleware(AgentMiddleware):
def __init__(self):
pass
def before_agent(self, state, runtime):
return {"x": state.get("x", 0) + 1} # Update graph state instead
```