By Bernat Sampera 2 min read Follow:

Changes in langchain and langgraph v1

What new things have been introduced in the v1 of langgraph and langchain? Read further to discover them and learn how to use it

The langchain team released langgraph and langchain v1 last week. Here are 5 new things.

1. The new create_agent primitive

New helper function that allows to create the agent with the tools, model and prompt.

 agent = create_agent( model=ChatOpenAI(model="gpt-4o"), tools=tool_node, prompt="You are a financial assistant." )
  1. Middleware API.

They also added a new middleware that can be added before/after a model execution or to modify the request to a model. Doesn’t seem that intuitive at first glance, would be nice to see how they use in some of their os repos.

from langchain.agents import create_agent
from langchain.agents.middleware import SummarizationMiddleware

agent = create_agent(
    model="openai:gpt-4o",
    tools=[weather_tool, calculator_tool],
    middleware=[
        SummarizationMiddleware(
            model="openai:gpt-4o-mini",
            max_tokens_before_summary=4000,  # Trigger summarization at 4000 tokens
            messages_to_keep=20,  # Keep last 20 messages after summary
            summary_prompt="Custom prompt for summarization...",  # Optional
        ),
    ],
)
  1. New structured output logic.

Now, instead of assigning the structured output to the instance of the llm, this can be specified for each tool in the agent. Like this.

def create_agent(…, 
    response_format: Union[
        ToolStrategy[StructuredResponseT],
        ProviderStrategy[StructuredResponseT],
        type[StructuredResponseT],
    ]
  1. New docs

    Imho so far the biggest highlight of the release, much more clear and structured than before.

  2. New Standard content blocks on messages.

    Also pretty useful! Before to display a message list like Toolmessage we saw a lot of noise like multiple ids or other data that it wasn’t that relevant . This will display just the type and content. Sounds good to just debug and see things with much more clarity.

Conclusion

Very nice to see the updates of the langchain community, it seems they are giving much more focus on the tool functionalities and how to work with them.

Haven’t seen yet anything on best practices to connect nodes, which for me was one of the biggest discoveries when looking at their repos, but let’s see maybe it comes in future releases.

Let's connect !!

Get in touch if you want updates, examples, and insights on how AI agents, Langchain and more are evolving and where they’re going next.