mirror of
https://github.com/langchain-ai/docs.git
synced 2026-08-27 21:00:00 -04:00
12 lines
269 B
Plaintext
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
|
|
```
|