Commit Graph

1270 Commits

Author SHA1 Message Date
John Kennedy
3fa6f5a48a Fix for First argument to super() is not enclosing class
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-02-27 15:42:51 -08:00
ccurme
94a58825d3 release(core): 1.2.16 (#35439) 2026-02-25 09:31:15 -05:00
Guofang.Tang
78678534f9 fix(core): treat empty tool chunk ids as missing in merge (#35414) 2026-02-24 18:12:49 -05:00
Tanzim Hossain Romel
2d1492a864 fix(core): improve error message for non-JSON-serializable tool schemas (#34376) 2026-02-22 17:32:00 -05:00
Balaji Seshadri
d6e46bb4b0 fix(core): improve typing/docs for on_chat_model_start to clarify required positional args (#35324) 2026-02-22 14:46:32 -05:00
Mason Daugherty
6199525f50 perf(core): defer specific langsmith imports to reduce import time (#35298)
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.
2026-02-21 00:29:35 -05:00
ccurme
00538ff5fc revert: add ChatAnthropicBedrockWrapper (#35371) 2026-02-20 15:58:35 -05:00
ccurme
bcfb87c211 release(core): 1.2.15 (#35367) 2026-02-20 13:44:26 -05:00
Mason Daugherty
ca246ddef2 fix(anthropic): replace retired model IDs in tests and docstrings (#35365)
## 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
2026-02-20 13:44:15 -05:00
NITIN Madan
63f3669e12 feat(anthropic): add ChatAnthropicBedrock wrapper (#35091) 2026-02-20 13:06:12 -05:00
ccurme
9851838eb8 release(core): 1.2.14 (#35328) 2026-02-19 09:18:24 -05:00
Mason Daugherty
18230f625f chore(core): remove langserve from sys info util, add deepagents (#35325)
getting with the times
2026-02-18 23:32:54 -05:00
yaowubarbara
5053436dcf fix(core): fix merge_lists incorrectly merging parallel tool calls (#35281) 2026-02-18 20:33:17 -05:00
Shivangi Sharma
3686bcbd96 fix(core): accept int temperature in _get_ls_params for LangSmith tracing (#35302) 2026-02-18 18:30:02 -05:00
ccurme
9c160e2368 revert: accept integer temperature values in _get_ls_params (#35319) 2026-02-18 18:19:28 -05:00
Balaji Seshadri
a9f3627229 fix(core): accept integer temperature values in _get_ls_params (#35317) 2026-02-18 17:52:13 -05:00
Eugene Yurtsev
8323f556d9 docs(core): update load note to be precise (#35309)
update load doc-string for precision
2026-02-18 15:22:59 -05:00
KarthikRed2000
a565cf85eb fix(core): prevent recursion error when args_schema is dict (#35260) 2026-02-17 17:47:17 -05:00
Mason Daugherty
ba3ad67328 fix(core): preserve index and timestamp fields when merging (#34731)
Porting https://github.com/langchain-ai/langchainjs/pull/9781
2026-02-17 11:29:41 -05:00
Mason Daugherty
0a561244f5 docs(core): add security warnings and best practices for deserialization (#35282) 2026-02-17 11:28:39 -05:00
Shivangi Sharma
f7dbdab5ba docs: fix docstring inaccuracies and update outdated LangSmith URLs (#35283)
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.*
2026-02-17 11:22:18 -05:00
Yi Liu
6a07b3acda fix(core): correct misleading jinja2 sandboxing comment (#35183)
## 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.
2026-02-16 23:17:22 -05:00
Mason Daugherty
b026fd605b release(core): 1.2.13 (#35230) 2026-02-15 02:42:13 -05:00
Mason Daugherty
1573757b3b docs(core): expanded get_lc_namespace docstring (#35229) 2026-02-15 02:39:39 -05:00
Mason Daugherty
f9fd7be695 feat(openrouter): add langchain-openrouter provider package (#35211)
Add a first-party `langchain-openrouter` partner package
(`ChatOpenRouter`) that wraps the official `openrouter` Python SDK,
providing native support for OpenRouter-specific features that
`ChatOpenAI` intentionally does not handle.

Also adds scope-clarifying docstrings to `ChatOpenAI` / `BaseChatOpenAI`
warning users away from using `base_url` overrides with third-party
providers.

---

Closes #31325
Closes #32967
Closes #32977
Closes #32981
Closes #33643
Closes #33757
Closes #34056
Closes #34797
Closes #34962

Supersedes #33902, #34867 (thank you @elonfeng and @okamototk for your
initial work on this!)

---

Bugs with upstream sdk:
- https://github.com/OpenRouterTeam/python-sdk/issues/38
- https://github.com/OpenRouterTeam/python-sdk/issues/51
- https://github.com/OpenRouterTeam/python-sdk/issues/52
2026-02-15 02:09:13 -05:00
Christophe Bornet
b97c629f9a style: bump ruff version to 0.15 (#35042) 2026-02-12 19:34:02 -05:00
ccurme
b06716fb87 release(core): 1.2.12 (#35192) 2026-02-12 15:49:14 -05:00
ccurme
16cabfa212 fix(core): fix setting ChatGeneration.text (#35191) 2026-02-12 15:43:53 -05:00
ccurme
524e1dab5e release(core): 1.2.11 (#35144) 2026-02-10 15:31:35 -05:00
ccurme
2b4b1dc29a fix(openai): sanitize urls when counting tokens in images (#35143) 2026-02-10 15:25:10 -05:00
Varun Chawla
a5f22e7cb1 chore(core): clean up docstring mismatch and redundant logic in langchain-core (#35064)
## 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.
2026-02-10 12:25:50 -05:00
Luka Aladashvili
97ee14c179 fix(core): replace bare except with Exception in tracer (#35138)
## 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.
2026-02-10 12:12:46 -05:00
ccurme
f41e049333 release(core): 1.2.10 (#35136) 2026-02-10 09:40:26 -05:00
ccurme
7c41298355 feat(core): add ContextOverflowError, raise in anthropic and openai (#35099) 2026-02-09 15:15:34 -05:00
Mason Daugherty
4ca586b322 feat(model-profiles): add text_inputs and text_outputs (#35084)
- 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
2026-02-09 14:50:09 -05:00
ccurme
e8e47b083e feat(core): count tokens from tool schemas in count_tokens_approximately (#35098) 2026-02-09 14:10:44 -05:00
Mason Daugherty
f0a808d969 docs(core): add missing name docstring for RunnableSerializable (#35088) 2026-02-09 01:59:44 -05:00
ccurme
3e3dbd9b88 release(core): 1.2.9 (#35025) 2026-02-05 09:17:54 -05:00
ccurme
032d01dd0f fix(core): adjust cap when scaling approximate token counts (#35017) 2026-02-04 19:02:48 -05:00
Mason Daugherty
9db00d3a6e revert: precompile hex color regex pattern at module level (#35016)
Reverts langchain-ai/langchain#34480
2026-02-04 16:47:52 -05:00
ccurme
5981ee142c fix(core): apply cap when scaling approximate token counts (#35005) 2026-02-03 21:20:48 -05:00
ccurme
09654f4382 feat(core): allow scaling by reported usage when counting tokens approximately (#34996) 2026-02-03 15:19:18 -05:00
ccurme
3f2f311dce release(core): 1.2.8 (#34975) 2026-02-02 10:31:21 -05:00
Mason Daugherty
3aca3fbebe docs(core): add examples for pretty_repr, pretty_print (#34968) 2026-02-01 16:37:03 -08:00
Mason Daugherty
12c34a4139 docs(core): use proper admonition for get_buffer_string (#34967) 2026-02-01 16:36:44 -08:00
XXt
6e307be101 docs: add usage examples to core classes (#34841) 2026-02-01 18:37:10 -05:00
Mason Daugherty
7c288f1650 chore(core): fix docstring format (#34966)
following #34860

list continuations must be indented for proper rendering in reference
docs
2026-02-01 14:48:02 -08:00
aahanabobade
7b4ced2d3b docs: add example to create_message function docstring (#34851) 2026-01-31 22:40:00 -05:00
shivangraikar
2063577d67 docs(core): clarify @tool decorator argument and return type requirements (#34860) 2026-01-31 22:39:35 -05:00
Nandana Dileep
ef067078b8 fix(core): fix nested mustache variable extraction and update docs (#34872) 2026-01-31 21:30:57 -05:00