Back Home

GitHub Repo

LangChain Anthropic 1.7.4 Supports Adding and Removing Tools Mid-Conversation

The new release lets agents adjust their toolset through system messages and adds beta headers based on message content. Cache benefits still depend on configuration and message placement, and handling of unknown system blocks has also changed.

Dirck van Baburen · Public domain · Image source
zh-Hant

LangChain released version 1.7.4 of its Anthropic integration package on September 23, adding support in system messages for native content blocks that add or remove tools mid-conversation. The proposal was submitted the previous day and merged on release day. Both the release notes and package registry have been updated, enabling long-running agents to adjust their available tools within the same conversation history. [Release notes](https://github.com/langchain-ai/langchain/releases/tag/langchain-anthropic==1.7.4), [PyPI](https://pypi.org/project/langchain-anthropic/1.7.4/).

This update fills a gap in the framework’s message conversion path. Developers can place `tool_addition` or `tool_removal` in a `SystemMessage`, either directly as dictionaries or wrapped in `non_standard` blocks. Native-format blocks are unwrapped and then preserved in the outgoing system messages. The code also adds the corresponding beta headers depending on whether the content contains tool references or complete definitions. [Change discussion](https://github.com/langchain-ai/langchain/pull/40758), [Public implementation](https://raw.githubusercontent.com/langchain-ai/langchain/master/libs/partners/anthropic/langchain_anthropic/chat_models.py).

The technical value lies in preserving the prompt prefix. The tools array precedes the cached conversation content, so modifying it directly invalidates the cache for subsequent content. Appending messages instead allows tools to become available or be withdrawn starting at a specified turn. If a tool’s schema is not known until runtime, inline definition mode can also supply the complete schema. For agent engineering, this provides an integration point for changing the toolset by task stage. However, caching must still be explicitly enabled; upgrading the package alone does not guarantee lower costs. [Claude documentation](https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages).

The upgrade also includes compatibility details: unknown blocks in system messages are now discarded with a warning. If a message is moved to the top level because of model or position restrictions, tool changes may also be removed. The initial system message, however, retains its blocks for server-side validation, so local rejection cannot be assumed in every case. [Public implementation](https://raw.githubusercontent.com/langchain-ai/langchain/master/libs/partners/anthropic/langchain_anthropic/chat_models.py).

For example, a multistage data analysis agent could initially offer retrieval tools, then add analysis tools once the data sources have been confirmed. This is a workflow the interface can support; the release provides no success-rate or cost benchmarks. Tool definition length, call frequency, and how conversation history is retained will still affect the benefits.

Deployment validation should therefore cover the actual tool list sent, warning logs, server-side errors, and cache hit counts. Withdrawing a tool only changes the options visible to the model going forward; the application must still enforce its own execution permissions. Teams should also test replaying conversation history after adding tools mid-conversation, ensuring that storage and restoration preserve these blocks in full, rather than merely checking that the model can respond successfully.

Sources

  1. Release langchain-anthropic==1.7.4
  2. langchain-anthropic 1.7.4
  3. Mid-conversation tool changes on SystemMessage — PR #40758
  4. ChatAnthropic 訊息轉換與測試版標頭實作
  5. Mid-conversation system messages and tool changes