[PR #5740] fix: Widen type annotations for dynamic models in create_react_agent #4619

Closed
opened 2026-02-20 17:50:29 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/5740

State: closed
Merged: No


Fixes #5739

Update type annotations in create_react_agent to support dynamic models that return LanguageModelLike (including results of bind_tools()).

Changes

  • Updated type annotations in chat_agent_executor.py to use LanguageModelLike instead of BaseChatModel
  • Updated docstrings to reflect the broader type acceptance
  • Maintained backward compatibility with existing BaseChatModel returns

Motivation

bind_tools() returns a Runnable[LanguageModelInput, BaseMessage], which was previously not supported by the type annotations. This change allows dynamic model callables to return the result of bind_tools() while keeping existing functionality intact.

Verification

  • Formatting checks passed
  • Linting checks passed
  • All tests passed successfully

Fixes the type annotation constraint that previously prevented using models with bound tools in dynamic model callables.

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/5740 **State:** closed **Merged:** No --- Fixes #5739 Update type annotations in `create_react_agent` to support dynamic models that return `LanguageModelLike` (including results of `bind_tools()`). ### Changes - Updated type annotations in `chat_agent_executor.py` to use `LanguageModelLike` instead of `BaseChatModel` - Updated docstrings to reflect the broader type acceptance - Maintained backward compatibility with existing `BaseChatModel` returns ### Motivation `bind_tools()` returns a `Runnable[LanguageModelInput, BaseMessage]`, which was previously not supported by the type annotations. This change allows dynamic model callables to return the result of `bind_tools()` while keeping existing functionality intact. ### Verification - Formatting checks passed - Linting checks passed - All tests passed successfully Fixes the type annotation constraint that previously prevented using models with bound tools in dynamic model callables.
yindo added the pull-request label 2026-02-20 17:50:29 -05:00
yindo closed this issue 2026-02-20 17:50:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#4619