I've been using LangChain for a while but find it a bit bloated. How does the compare when it comes to maintaining conversation history and session state across multiple turns? Is it more lightweight?
3 answers
The philosophy of the OpenAI Agents SDK is simplicity. It focuses on four core primitives: Agents, Handoffs, Guardrails, and Sessions. Unlike LangChain, which has a vast library of abstractions, the Agents SDK stays "out of the way" of the developer. For state management, it uses a 'Session' object that can automatically handle conversation history. It even supports Redis for persistent sessions across different runs. It feels much more like writing standard Python code rather than learning a new DSL, which makes debugging and scaling much easier for production.
Does it support structured outputs natively, or do we still need to use Pydantic to parse the responses?
It’s definitely more lightweight. I switched my project last month and reduced my codebase by about 30 percent.
That’s a huge improvement, Heather! I think the "Python-first" approach is why so many people are making the move.
Ronald, it integrates perfectly with Pydantic! You can define an 'output_type' for your agent using a Pydantic model, and the SDK ensures the model follows that schema. This is especially useful for RPA tasks where you need the agent to return data in a specific JSON format for the next step in your automation pipeline. It’s very clean and avoids the "hallucinated format" issues you sometimes see with less structured frameworks.