Commit Graph

14373 Commits

Author SHA1 Message Date
Mason Daugherty
f6cf4fcd6e Merge branch 'master' into wip-v1.0 2025-09-23 01:27:12 -04:00
Mason Daugherty
9c1285cf5b chore(infra): fix ping pong pr labeler config (#33054)
The title-based labeler was clearing all pre-existing labels (including
the file-based ones) before adding its semantic labels.
2025-09-22 21:19:53 -04:00
Sydney Runkle
c3be45bf14 fix(langchain): HITL bug causing dupe interrupt (#33052)
Need to find **last** AI msg (not first). Getting too creative w/
generators.
langchain==1.0.0a7
2025-09-22 20:09:12 -04:00
Mason Daugherty
cfa9973828 Merge branch 'master' into wip-v1.0 2025-09-22 16:30:00 -04:00
Arman Tsaturian
8f488d62b2 docs: fix stripe toolkit import in the guide (#33044)
**Description:**
Stripe tools integration guide incorrectly referenced the `crewai`
toolkit. Updated the import to use the correct `langchain` toolkit.

Stripe docs reference:
https://docs.stripe.com/agents?framework=langchain&lang=python
2025-09-22 15:17:09 -04:00
Mason Daugherty
cdae9e4942 fix(infra): prevent labeler workflow from adding/removing same labels (#33039)
The file-based and title-based labeler workflows were conflicting,
causing the bot to add and remove identical labels in the same
operation. Hopefully this fixes
2025-09-21 04:37:59 +00:00
Mason Daugherty
e75878bfa2 Merge branch 'master' into wip-v1.0 2025-09-21 00:29:30 -04:00
Mason Daugherty
7ddc798f95 fix(openai): pin upper bound to prevent Pydantic 2.7.0 issues (#33038)
https://github.com/openai/openai-python/issues/2644
2025-09-21 00:27:03 -04:00
Mason Daugherty
6081ba9184 fix: pydantic openai (#33037) 2025-09-21 00:21:56 -04:00
Mason Daugherty
0cc6f8bb58 Merge branch 'master' into wip-v1.0 2025-09-20 23:47:53 -04:00
Mason Daugherty
7dcf6a515e fix: update method calls from dict to model_dump in Chain (#33035) 2025-09-20 23:47:44 -04:00
Mason Daugherty
043a7560a5 test: use .get() for safe ls_params access (#33034) 2025-09-20 23:46:37 -04:00
Mason Daugherty
6c90ba1f05 test: fix pydantic issue by bumping OAI-py 2025-09-20 23:13:42 -04:00
Mason Daugherty
ea3b9695e6 Merge branch 'master' into wip-v1.0 2025-09-20 22:59:25 -04:00
Mason Daugherty
5b418d3f26 feat(infra): add PR labeler configurations and workflows (#33031) 2025-09-20 22:33:08 -04:00
Mason Daugherty
6b4054c795 chore(infra): update pre-commit hooks to include linting (#33029) 2025-09-21 02:26:19 +00:00
Mason Daugherty
30fde5af38 chore(infra): remove couchbase formatting hook from pre-commit (#33030)
Should've been done when it was removed from the monorepo
2025-09-20 22:09:57 -04:00
Mason Daugherty
781db9d892 chore: update pyproject.toml files, remove codespell (#33028)
- Removes Codespell from deps, docs, and `Makefile`s
- Python version requirements in all `pyproject.toml` files now use the
`~=` (compatible release) specifier
- All dependency groups and main dependencies now use explicit lower and
upper bounds, reducing potential for breaking changes
2025-09-20 22:09:33 -04:00
Sydney Runkle
f2b0afd0b7 release(langchain): 1.0.0a6 (#33024)
w/ improvements to HITL, state schema merging, dynamic system prompt
langchain==1.0.0a6
2025-09-19 18:47:41 +00:00
Sydney Runkle
c3654202a3 fix(langchain): use state schema as input schema to middleware nodes (#33023)
We want state schema as the input schema to middleware nodes because the
conditional edges after these nodes need access to the full state.

Also, we just generally want all state passed to middleware nodes, so we
should be specifying this explicitly. If we don't, the state annotations
used by users in their node signatures are used (so they might be
missing fields).
2025-09-19 18:43:33 +00:00
Chester Curme
fa4c302463 fix(anthropic): fix web_fetch test 2025-09-19 09:32:30 -04:00
Sydney Runkle
4d118777bc feat(langchain): dynamic system prompt middleware (#33006)
# Changes

## Adds support for `DynamicSystemPromptMiddleware`

```py
from langchain.agents.middleware import DynamicSystemPromptMiddleware
from langgraph.runtime import Runtime
from typing_extensions import TypedDict

class Context(TypedDict):
    user_name: str

def system_prompt(state: AgentState, runtime: Runtime[Context]) -> str:
    user_name = runtime.context.get("user_name", "n/a")
    return f"You are a helpful assistant. Always address the user by their name: {user_name}"

middleware = DynamicSystemPromptMiddleware(system_prompt)
```

## Adds support for `runtime` in middleware hooks

```py
class AgentMiddleware(Generic[StateT, ContextT]):
    def modify_model_request(
        self,
        request: ModelRequest,
        state: StateT,
        runtime: Runtime[ContextT],  # Optional runtime parameter
    ) -> ModelRequest:
        # upgrade model if runtime.context.subscription is `top-tier` or whatever
```

## Adds support for omitting state attributes from input / output
schemas

```py
from typing import Annotated, NotRequired
from langchain.agents.middleware.types import PrivateStateAttr, OmitFromInput, OmitFromOutput

class CustomState(AgentState):
    # Private field - not in input or output schemas
    internal_counter: NotRequired[Annotated[int, PrivateStateAttr]]
    
    # Input-only field - not in output schema
    user_input: NotRequired[Annotated[str, OmitFromOutput]]
    
    # Output-only field - not in input schema  
    computed_result: NotRequired[Annotated[str, OmitFromInput]]
```

## Additionally
* Removes filtering of state before passing into middleware hooks

Typing is not foolproof here, still need to figure out some of the
generics stuff w/ state and context schema extensions for middleware.

TODO:
* More docs for middleware, should hold off on this until other prios
like MCP and deepagents are met

---------

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
2025-09-18 16:07:16 -04:00
ccurme
b215ed5642 chore(langchain): (v1) drop python 3.9 and relax dependency bounds (#33013) 2025-09-18 15:05:50 -04:00
Chester Curme
c891a51608 fix(infra): permit pre-releases in release workflow langchain-core==1.0.0a4 2025-09-18 13:44:54 -04:00
ccurme
82650ea7f1 release(core): 1.0.0a4 (#33011) 2025-09-18 13:01:02 -04:00
ccurme
13964efccf revert: fix(standard-tests): add filename to PDF file block (#33010)
Reverts langchain-ai/langchain#32989 in favor of
https://github.com/langchain-ai/langchain/pull/33009.
2025-09-18 12:48:00 -04:00
ccurme
f247270111 feat(core): (v1) standard content for AWS (#32969)
https://github.com/langchain-ai/langchain-aws/pull/643
2025-09-18 12:47:26 -04:00
ccurme
8be4adccd1 fix(core): (v1) trace PDFs in v0 standard format (#33009) 2025-09-18 11:45:12 -04:00
Mason Daugherty
b6bd507198 Merge branch 'master' into wip-v1.0 2025-09-18 11:44:06 -04:00
Mason Daugherty
f158cea1e8 release(mistralai): 0.2.12 (#33008) langchain-mistralai==0.2.12 2025-09-18 11:42:11 -04:00
Mason Daugherty
3e0d7512ef core: update version.py langchain-core==1.0.0a3 2025-09-18 10:58:51 -04:00
Mason Daugherty
53ed770849 Merge branch 'master' into wip-v1.0 2025-09-18 10:57:53 -04:00
Mason Daugherty
e2050e24ef release(core): 1.0.0a3 2025-09-18 10:57:22 -04:00
Sadiq Khan
90280d1f58 docs(core): fix bugs and improve example code in chat_history.py (#32994)
## Summary

This PR fixes several bugs and improves the example code in
`BaseChatMessageHistory` docstring that would prevent it from working
correctly.

### Bugs Fixed
- **Critical bug**: Fixed `json.dump(messages, f)` →
`json.dump(serialized, f)` - was using wrong variable
- **NameError**: Fixed bare variable references to use
`self.storage_path` and `self.session_id`
- **Missing imports**: Added required imports (`json`, `os`, message
converters) to make example runnable

### Improvements
- Added missing type hints following project standards (`messages() ->
list[BaseMessage]`, `clear() -> None`)
- Added robust error handling with `FileNotFoundError` exception
handling
- Added directory creation with `os.makedirs(exist_ok=True)` to prevent
path errors
- Improved performance: `json.load(f)` instead of `json.loads(f.read())`
- Added explicit UTF-8 encoding to all file operations
- Updated stores.py to use modern union syntax (`int | None` vs
`Optional[int]`)

### Test Plan
- [x] Code passes linting (`ruff check`)
- [x] Example code now has all required imports and proper syntax
- [x] Fixed variable references prevent runtime errors
- [x] Follows project's type annotation standards

The example code in the docstring is now fully functional and follows
LangChain's coding standards.

---------

Co-authored-by: sadiqkhzn <sadiqkhzn@users.noreply.github.com>
2025-09-18 09:34:19 -04:00
Dushmanta
ee340e0a3b fix(docs): update dead link to docling github and docs (#33001)
- **Description:** Updated the dead/unreachable links to Docling from
the additional resources section of the langchain-docling docs
  - **Issue:** Fixes langchain-ai/docs/issues/574
  - **Dependencies:** None
2025-09-18 09:30:29 -04:00
Sydney Runkle
d5ba5d3511 feat(langchain): improved HITL patterns (#32996)
# Main changes / new features

## Better support for parallel tool calls

1. Support for multiple tool calls requiring human input
2. Support for combination of tool calls requiring human input + those
that are auto-approved
3. Support structured output w/ tool calls requiring human input
4. Support structured output w/ standard tool calls

## Shortcut for allowed actions

Adds a shortcut where tool config can be specified as a `bool`, meaning
"all actions allowed"

```py
HumanInTheLoopMiddleware(tool_configs={"expensive_tool": True})
```

## A few design decisions here
* We only raise one interrupt w/ all `HumanInterrupt`s, currently we
won't be able to execute all tools until all of these are resolved. This
isn't super blocking bc we can't re-invoke the model until all tools
have finished execution. That being said, if you have a long running
auto-approved tool, this could slow things down.

## TODOs

* Ideally, we would rename `accept` -> `approve`
* Ideally, we would rename `respond` -> `reject`
* Docs update (@sydney-runkle to own)
* In another PR I'd like to refactor testing to have one file for each
prebuilt middleware :)

Fast follow to https://github.com/langchain-ai/langchain/pull/32962
which was deemed as too breaking
2025-09-17 16:53:01 -04:00
Mason Daugherty
76d0758007 fix(docs): json_mode -> json_schema (#32993) 2025-09-17 18:21:34 +00:00
Mason Daugherty
8b3f74012c docs: update GenAI structured output section to include JSON mode details (#32992) 2025-09-17 17:40:34 +00:00
Mason Daugherty
59bb8bffd1 feat(core): make is_openai_data_block public and add filtering (#32991) 2025-09-17 11:41:41 -04:00
Mason Daugherty
16ec9bc535 fix(core): add back text to data content block check 2025-09-17 11:13:27 -04:00
Mason Daugherty
fda8a71e19 docs: further comments for clarity 2025-09-17 00:57:48 -04:00
Mason Daugherty
8f23bd109b fix: correct var name in comment 2025-09-17 00:39:01 -04:00
Mason Daugherty
ff632c1028 fix(standard-tests): add filename to PDF file block (#32989)
The standard PDF input test was creating file content blocks without a
filename field.

This caused a warning when the OpenAI block translator processed the
message for LangSmith tracing, since OpenAI requires filenames for file
inputs.
2025-09-17 00:35:49 -04:00
Mason Daugherty
3f71efc93c docs(core): update comments and docstrings 2025-09-17 00:35:30 -04:00
Mason Daugherty
cb3b5bf69b refactor(core): remove Pydantic v2 deprecation warning in tools base module
Replace deprecated `__fields__` attribute access with proper version-agnostic field retrieval using existing `get_fields`
2025-09-16 23:58:37 -04:00
Mason Daugherty
1c8a01ed03 cli: remove unnecessary changes & bump lock 2025-09-16 22:12:26 -04:00
Mason Daugherty
25333d3b45 Merge branch 'master' into wip-v1.0 2025-09-16 22:09:23 -04:00
Mason Daugherty
54a9556f5c chore(cli): update lock (#32986) 2025-09-17 02:08:20 +00:00
Mason Daugherty
42830208f3 Merge branch 'master' into wip-v1.0 2025-09-16 22:04:42 -04:00
Mason Daugherty
66041a2778 refactor(cli): target ruff 310 (#32985)
Use union types for optional parameters
2025-09-16 22:04:28 -04:00