Commit Graph

1287 Commits

Author SHA1 Message Date
ccurme
d22df94537 release(core): 1.2.22 (#36201) 2026-03-24 14:45:30 -04:00
ccurme
27add91347 fix(core): validate paths in prompt.save and load_prompt, deprecate methods (#36200) 2026-03-24 14:27:14 -04:00
ccurme
19f81cf6f1 release(core): 1.2.21 (#36179) 2026-03-23 13:57:14 -04:00
Mason Daugherty
2f64d80cc6 fix(core,model-profiles): add missing ModelProfile fields, warn on schema drift (#36129)
PR #35788 added 7 new fields to the `langchain-profiles` CLI output
(`name`, `status`, `release_date`, `last_updated`, `open_weights`,
`attachment`, `temperature`) but didn't update `ModelProfile` in
`langchain-core`. Partner packages like `langchain-aws` that set
`extra="forbid"` on their Pydantic models hit `extra_forbidden`
validation errors when Pydantic encountered undeclared TypedDict keys at
construction time. This adds the missing fields, makes `ModelProfile`
forward-compatible, provides a base-class hook so partners can stop
duplicating model-profile validator boilerplate, migrates all in-repo
partners to the new hook, and adds runtime + CI-time warnings for schema
drift.

## Changes

### `langchain-core`
- Add `__pydantic_config__ = ConfigDict(extra="allow")` to
`ModelProfile` so unknown profile keys pass Pydantic validation even on
models with `extra="forbid"` — forward-compatibility for when the CLI
schema evolves ahead of core
- Declare the 7 missing fields on `ModelProfile`: `name`, `status`,
`release_date`, `last_updated`, `open_weights` (metadata) and
`attachment`, `temperature` (capabilities)
- Add `_warn_unknown_profile_keys()` in `model_profile.py` — emits a
`UserWarning` when a profile dict contains keys not in `ModelProfile`,
suggesting a core upgrade. Wrapped in a bare `except` so introspection
failures never crash model construction
- Add `BaseChatModel._resolve_model_profile()` hook that returns `None`
by default. Partners can override this single method instead of
redefining the full `_set_model_profile` validator — the base validator
calls it automatically
- Add `BaseChatModel._check_profile_keys` as a separate
`model_validator` that calls `_warn_unknown_profile_keys`. Uses a
distinct method name so partner overrides of `_set_model_profile` don't
inadvertently suppress the check

### `langchain-profiles` CLI
- Add `_warn_undeclared_profile_keys()` to the CLI (`cli.py`), called
after merging augmentations in `refresh()` — warns at profile-generation
time (not just runtime) when emitted keys aren't declared in
`ModelProfile`. Gracefully skips if `langchain-core` isn't installed
- Add guard test
`test_model_data_to_profile_keys_subset_of_model_profile` in
model-profiles — feeds a fully-populated model dict to
`_model_data_to_profile()` and asserts every emitted key exists in
`ModelProfile.__annotations__`. CI fails before any release if someone
adds a CLI field without updating the TypedDict

### Partner packages
- Migrate all 10 in-repo partners to the `_resolve_model_profile()`
hook, replacing duplicated `@model_validator` / `_set_model_profile`
overrides: anthropic, deepseek, fireworks, groq, huggingface, mistralai,
openai (base + azure), openrouter, perplexity, xai
- Anthropic retains custom logic (context-1m beta → `max_input_tokens`
override); all others reduce to a one-liner
- Add `pr_lint.yml` scope for the new `model-profiles` package
2026-03-23 00:44:27 -04:00
ccurme
c4abc91ed9 release(core): 1.2.20 (#36085) 2026-03-18 13:31:33 -04:00
ccurme
70c88c0e72 fix(core): trace invocation params in metadata (#36080) 2026-03-18 13:20:18 -04:00
Tanushree
2319fdc978 feat: Add LangSmith integration metadata to create_agent and init_chat_model (#35810) 2026-03-18 11:24:08 -04:00
Eugene Yurtsev
dd136337d7 feat(core): harden anti-ssrf (#35960)
harden anti-ssrf

---------

Co-authored-by: Mason Daugherty <mason@langchain.dev>
2026-03-18 10:41:43 -04:00
Eugene Yurtsev
a17445bbfd docs(core): document base_url in mermaid api (#35961)
adding documentation to base_url to stop the noise

Co-authored-by: Mason Daugherty <mason@langchain.dev>
2026-03-17 12:16:39 -04:00
Mason Daugherty
9b22f9c450 chore: housekeeping (#35850) 2026-03-13 16:24:35 -04:00
ccurme
41cca203e6 release(core): 1.2.19 (#35832) 2026-03-13 09:41:49 -04:00
ccurme
307cdcac9e chore(core): move BaseCrossEncoder to langchain-core (#35809) 2026-03-12 20:12:42 -04:00
ccurme
6b25caf1ae release(core): 1.2.18 (#35704) 2026-03-09 16:36:50 -04:00
Ethan T.
f838c78788 fix(core): fix double backticks in deprecation docstring for alternative_import (#35658) 2026-03-08 15:36:04 -04:00
Mohammad Mohtashim
b21c0a8062 fix(core): preserve default_factory when generating tool call schema (#35550) 2026-03-08 15:34:21 -04:00
ccurme
fbfe4b812d feat(openai): support tool search (#35582) 2026-03-08 08:53:13 -04:00
Mason Daugherty
cdf140e77d release(core): 1.2.17 (#35527) 2026-03-02 17:44:57 -05:00
Mason Daugherty
61fd90a2f3 fix(core): extract usage metadata from serialized tracer message outputs (#35526)
Fixes missing `run.metadata.usage_metadata` population in
`LangChainTracer` for real LLM/chat traces following #34414

- Fix extraction to read usage from serialized tracer message shape:
`outputs.generations[*][*].message.kwargs.usage_metadata`
- Remove non-serialized direct message shape handling
(`message.usage_metadata`) from extractor to match real tracer output
path
- Clarify tracer docstrings around chat callback naming
(`on_chat_model_start` + shared `on_llm_end`) to reduce ambiguity

## Why

#34414 introduced usage duplication into `run.metadata.usage_metadata`,
but the extractor read `message.usage_metadata`.

In real tracer flow, messages are serialized with `dumpd(...)` during
run completion, so usage metadata lives under
`message.kwargs.usage_metadata`. Because of this mismatch, duplication
did not trigger in real traces.
2026-03-02 17:43:33 -05: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