Skip to main content
Inside a trace, use the middleware for create_agent, or wrap the chat model for anything else (LangGraph nodes, prebuilt agents, structured output). Use one per model. Put the middleware last, so it records the model and prompt that other middleware settled on, and each retry by other middleware as its own step.
Lessons are one temporary user message at the end of the request; the agent’s messages are never changed. Outside a trace, calls pass through unrecorded, and if Sovara is unavailable they still run. Requires langchain-core 1.x (langchain 1.1+ for the middleware) in Python, or @langchain/core 1.2+ (langchain 1.5+ for the middleware) in TypeScript.