- Add copy-on-write (COW) to BaseCallbackManager.copy() — defer
shallow copies of handlers/tags/metadata until first mutation
- Cache inspect.signature() results for BaseChatModel._generate and
_agenerate to avoid repeated introspection per invoke
- Cache signature(self._run) and _get_runnable_config_param in
ChildTool.__init__ to avoid per-invocation introspection
- Convert CONFIG_KEYS and COPIABLE_KEYS from lists to frozensets
for O(1) membership checks
- Fast path in _format_for_tracing when no messages have list content
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- get_child(): pass state directly to constructor instead of calling
set_handlers/add_tags/add_metadata sequentially (-22%)
- add_tags(): use set-based dedup instead of O(n) list scans per tag,
early return when tags list is empty (-70% on duplicate tags)
- handle_event/ahandle_event: early return when handlers list is empty
- _configure(): skip throwaway CallbackManager construction on the
common path where inheritable_callbacks is provided
These are the top bottlenecks identified by profiling langgraph's
react_agent benchmark, where langchain_core callbacks account for ~35%
of runtime.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Defer `langsmith` and tracer imports in `callbacks/manager.py` and
`runnables/config.py` from module-level to function-level.
These imports pull in the full `langsmith` package (~132ms) at import
time but are only used inside `_configure()`, `trace_as_chain_group()`,
`_set_config_context()`, and `set_config_context()` — none of which run
during module initialization.
## Summary
- Replace `claude-3-5-haiku-20241022` and `claude-3-7-sonnet-20250219`
with `claude-haiku-4-5-20251001` and `claude-sonnet-4-5-20250929`
respectively
- Both models were retired by Anthropic on February 19, 2026, causing
all anthropic integration tests to fail
- Updates integration tests, a unit test, and docstring examples in
`langchain-core`
See:
https://platform.claude.com/docs/en/docs/resources/model-deprecations
Fix several docstring inaccuracies in langchain-core and update outdated
LangSmith URLs across three README files.
**Docstring fixes (libs/core):**
- `tap_output_iter`: docstring says "async iterator" but method accepts
sync `Iterator`
- `agenerate_from_stream`: docstring says "Iterator" but method accepts
`AsyncIterator`
- `BaseLLM.OutputType`: docstring says "input type" but property returns
output type
- Grammar: "or deprecated" → "or be deprecated", "relies" → "rely",
"whose the" → "whose"
**URL fixes (libs/core, libs/langchain, libs/langchain_v1):**
- Updated `smith.langchain.com` → `www.langchain.com/langsmith` (root
README already uses the correct URL)
Verified with `make lint` and `make format` in libs/core — no new issues
introduced. Changes are docs-only with no code logic impact.
*This PR was created with assistance from an AI coding tool.*
## Summary
- The inline comment at `langchain_core/prompts/string.py:67-69`
incorrectly states that `SandboxedEnvironment` "blocks ALL
attribute/method access" and that "only simple variable lookups like
`{{variable}}` are allowed."
- In reality, Jinja2's `SandboxedEnvironment` only blocks access to
dunder attributes (`__class__`, `__globals__`, etc.) to prevent sandbox
escapes. Regular attribute access like `{{obj.content}}` and method
calls remain allowed.
- This misleading comment was left behind when a
`_RestrictedSandboxedEnvironment` class was reverted in commit
395c8d0bd4. Updated to accurately describe the actual behavior.
## Why this matters
The comment could mislead developers into trusting partially-untrusted
templates, believing attribute access is blocked when it is not. The
function's docstring already correctly warns against untrusted
templates.
## Test plan
- [ ] No behavioral change — comment-only fix
- [ ] Verified `SandboxedEnvironment` behavior matches updated comment
> This PR was authored with the help of AI tools.
## Description
Fixes#35046
Two minor cleanups in `langchain-core`:
1. **Fix docstring mismatch in `mustache.render()`**: The docstring
incorrectly documented `partials_path` and `partials_ext` parameters
that do not exist in the function signature. These were likely carried
over from the original
[chevron](https://github.com/noahmorrison/chevron) library but were
never part of this adapted implementation.
2. **Remove redundant logic in `Blob.from_path()`**: The expression
`mimetypes.guess_type(path)[0] if guess_type else None` had a redundant
`if guess_type` ternary since the outer condition `if mime_type is None
and guess_type:` already guarantees `guess_type` is `True` at that
point. Simplified to just `mimetypes.guess_type(path)[0]`.
## AI Disclaimer
An AI coding assistant was used to help identify and implement these
changes.
## Description
This PR replaces a bare `except:` clause with `except Exception:` in
`libs/core/langchain_core/tracers/core.py`.
The previous implementation caught `BaseException`, which includes
`SystemExit` and `KeyboardInterrupt`. This meant that if a user tried to
interrupt the program (Ctrl+C) during a traceback formatting error, the
signal would be suppressed, potentially making the process un-killable.
This change ensures that standard runtime errors are still caught and
logged, but system control signals are allowed to propagate correctly.
## Verification
- Verified via code inspection.
- This is a standard safety fix for exception handling patterns in
Python to avoid suppressing system exit signals.
- Add `text_inputs` and `text_outputs` fields to `ModelProfile`
- Regenerate `_profiles.py` for all providers
## Why
models.dev data includes `'text'` as both an input and output modality,
but we didn't capture it.
models.dev broadly contains models without text input (Whisper/ASR) and
without text output (image generators, TTS).
Without this, downstream consumers can't filter on model text support
(e.g. preventing users from passing text input to an audio-only model).
---
We'd need to also run for Google, AWS and cut releases for all to
propagate