Change8

langchain==1.4.0a1

📦 langchainView on GitHub →
17 features🐛 33 fixes1 deprecations🔧 24 symbols

Summary

This release introduces significant improvements to the MCP (Multi-modal Conversational Protocol) handling, including new elicitation features and tool conversion. It also brings general bug fixes and refactors across various components.

Migration Steps

  1. Drop `MCPAdapter.aclose`.

✨ New Features

  • Answer MCP elicitation with a LangGraph interrupt.
  • Port MCP tool conversion from `langchain-mcp-adapters`.
  • Simplify `MCPAdapter` construction.
  • Introduce `langchain.mcp` namespace and `MCPAdapter`.
  • Add standard model exception types.
  • Support custom `token_counter` in `ContextEditingMiddleware`.
  • Expose `trace_policy` on `AgentMiddleware`.
  • Add `state_schema` parameter to `wrap_tool_call`.
  • Filter internal middleware model calls from `messages` projection.
  • Add LangSmith provider to `init_chat_model`.
  • Add `reasoning_effort` as a standard chat model parameter.
  • Introduce `ToolErrorMiddleware`.
  • Add `meta` extra and support `langchain-meta` in `init_chat_model`.
  • Support explicit prompt caching in OpenAI.
  • Add `ProviderToolSearchMiddleware`.
  • Port AND-capable trigger conditions to `SummarizationMiddleware`.
  • Support `apply_patch` built-in tool in OpenAI.

🐛 Bug Fixes

  • Name the content type MCP conversion could not handle.
  • Review edits for `langchain/mcp`.
  • Import `assert_never` from `typing_extensions`.
  • Make the two FastMCP-private dependencies fail loudly.
  • Bound the MCP input-required retry loop.
  • Preserve content-block shape in PIIMiddleware redaction.
  • Shore up indexing in genai v1 streaming content.
  • Guard MCP elicitation calls against a dying session.
  • Frame custom HITL rejection reasons.
  • Re-raise non-retryable exceptions in `ModelRetryMiddleware`.
  • Update docs on error handling for json schema.
  • Preserve final repeated schema ordering.
  • Preserve history on `SummarizationMiddleware` summary failure.
  • Handle import error in `LLMToolEmulator` by `model`.
  • Re-export `PIIMatch` from `middleware` package.
  • Restrict narrowed `ToolStrategy` in bound tools.
  • Handle malformed structured-output responses.
  • Prevent orphaned `tool_calls` in `ToolCallLimitMiddleware` end behavior.
  • Add aliases for bedrock mantle chat models.
  • Clear stale `structured_response` between checkpointed turns.
  • Stop HITL approval gates from silently failing open.
  • Propagate model middleware control flow.
  • Update Anthropic config test.
  • Only retry retryable exceptions in `ToolRetryMiddleware`.
  • Propagate interrupts through `ToolRetryMiddleware`.
  • Avoid shared process-group kill in shell middleware.
  • Sanitize anthropic cache markers on fallback retries.
  • Only set `strict=True` on tools for OpenAI-compatible models in `ProviderStrategy`.
  • Switch summary format.
  • Detect provider strategy for dated `gpt-5.2`/`gpt-5.4` snapshots.
  • Confine file-search results and tighten anthropic `allowed_prefixes`.
  • Tighten structured output model fallbacks.
  • Preserve summarization trigger compatibility.

Affected Symbols

⚡ Deprecations

  • Legacy trigger view marked for 2.0 removal.