Change8

langchain-core==1.4.0a2

📦 langchainView on GitHub →
14 features🐛 35 fixes1 deprecations🔧 22 symbols

Summary

This release introduces content-block-centric streaming (v2) and support for the v3 stream protocol, alongside numerous bug fixes related to tracing, validation, and dependency updates. Path saving/loading functions for prompts have been deprecated.

Migration Steps

  1. If you rely on path validation in `prompt.save` or `load_prompt`, update your usage as these methods are now deprecated.

✨ New Features

  • Implemented content-block-centric streaming (v2) for core functionality.
  • Added support for `stream_events(version='v3')` protocol.
  • Allowed `_format_output` to pass through a list of `ToolOutputMixin` instances.
  • Updated inheritance behavior for tracer metadata for special keys.
  • Added chat model and LLM invocation parameters to traceable metadata.
  • Added `ChatBaseten` to the serializable mapping.
  • Imputed placeholder filenames for OpenAI file inputs.
  • Added LangSmith integration metadata to `create_agent` and `init_chat_model`.
  • Added `ContextOverflowError` and raised it in Anthropic and OpenAI integrations.
  • Added `text_inputs` and `text_outputs` to `ModelProfiles`.
  • Enabled counting tokens from tool schemas in `count_tokens_approximately`.
  • Allowed scaling by reported usage when counting tokens approximately.
  • Added `langchain-openrouter` provider package.
  • Added support for tool search in OpenAI.

🐛 Bug Fixes

  • Preserved structured `inputs` on tool runs in tracers.
  • Made `removal` optional in `warn_deprecated`.
  • Validated `batch_size` in `_batch` and `_abatch` to prevent infinite loops.
  • Restored cloud metadata IPs and link-local range in SSRF policy.
  • Handled content blocks without a type key in OpenAI responses API conversion.
  • Used reference counting for storing inherited run trees to support garbage collection.
  • Added more sanitization to templates.
  • Handled symlinks in deprecated prompt save paths.
  • Added init validator and serialization mappings for Bedrock models.
  • Hardened check for txt files in deprecated prompt loading functions.
  • Corrected parameter names in `filter_messages` docstring example.
  • Fixed typos in the documentation.
  • Added "computer" to `_WellKnownOpenAITools`.
  • Validated paths in `prompt.save` and `load_prompt` (leading to deprecation).
  • Added missing `ModelProfile` fields and warned on schema drift.
  • Traced invocation parameters in metadata.
  • Fixed double backticks in deprecation docstring for `alternative_import`.
  • Preserved `default_factory` when generating tool call schema.
  • Extracted usage metadata from serialized tracer message outputs.
  • Treated empty tool chunk ids as missing in merge operations.
  • Improved error message for non-JSON-serializable tool schemas.
  • Improved typing/docs for `on_chat_model_start` to clarify required positional arguments.
  • Fixed merge_lists incorrectly merging parallel tool calls.
  • Accepted integer temperature in `_get_ls_params` for LangSmith tracing (reverted and then fixed again).
  • Accepted integer temperature values in `_get_ls_params`.
  • Prevented recursion error when `args_schema` is a dict.
  • Preserved index and timestamp fields when merging.
  • Corrected misleading jinja2 sandboxing comment.
  • Fixed setting `ChatGeneration.text`.
  • Sanitized URLs when counting tokens in images.
  • Replaced bare except with `Exception` in tracer.
  • Adjusted cap when scaling approximate token counts.
  • Applied cap when scaling approximate token counts.
  • Replaced retired model IDs in Anthropic tests and docstrings.
  • Fixed docstring format.

Affected Symbols

⚡ Deprecations

  • Validation of paths in `prompt.save` and `load_prompt` functions was added, and these methods are now deprecated (see fix #36200).