Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/langchain_v1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ coverage:
$(TEST_FILE)

test:
make start_services && LANGGRAPH_TEST_FAST=0 uv run --group test pytest -n auto --disable-socket --allow-unix-socket $(TEST_FILE) --cov-report term-missing:skip-covered; \
make start_services && LANGGRAPH_TEST_FAST=0 uv run --no-sync --active --group test pytest -n auto --disable-socket --allow-unix-socket $(TEST_FILE) --cov-report term-missing:skip-covered; \
EXIT_CODE=$$?; \
make stop_services; \
exit $$EXIT_CODE
Expand Down
10 changes: 5 additions & 5 deletions libs/langchain_v1/langchain/agents/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from langgraph._internal._runnable import RunnableCallable
from langgraph.constants import END, START
from langgraph.graph.state import StateGraph
from langgraph.prebuilt.tool_node import ToolCallWithContext, ToolNode
from langgraph.runtime import Runtime # noqa: TC002
from langgraph.types import Command, Send
from langgraph.typing import ContextT # noqa: TC002
Expand All @@ -37,7 +38,6 @@
ToolStrategy,
)
from langchain.chat_models import init_chat_model
from langchain.tools.tool_node import ToolCallWithContext, _ToolNode

if TYPE_CHECKING:
from collections.abc import Awaitable, Callable, Sequence
Expand All @@ -48,7 +48,7 @@
from langgraph.store.base import BaseStore
from langgraph.types import Checkpointer

from langchain.tools.tool_node import ToolCallRequest, ToolCallWrapper
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is still there for backwards compat, but I think from middleware is good for now

from langchain.agents.middleware.types import ToolCallRequest, ToolCallWrapper
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to import this from middleware.types or from langgraph.prebuilt.tool_node directly?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something in langchain since langchain users will be working with that import rather than with an import from langgraph.prebuilt.tool_node

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't really think it matters


STRUCTURED_OUTPUT_ERROR_TEMPLATE = "Error: {error}\n Please fix your mistakes."

Expand Down Expand Up @@ -675,7 +675,7 @@ def check_weather(location: str) -> str:
awrap_tool_call_wrapper = _chain_async_tool_call_wrappers(async_wrappers)

# Setup tools
tool_node: _ToolNode | None = None
tool_node: ToolNode | None = None
# Extract built-in provider tools (dict format) and regular tools (BaseTool/callables)
built_in_tools = [t for t in tools if isinstance(t, dict)]
regular_tools = [t for t in tools if not isinstance(t, dict)]
Expand All @@ -685,7 +685,7 @@ def check_weather(location: str) -> str:

# Only create ToolNode if we have client-side tools
tool_node = (
_ToolNode(
ToolNode(
tools=available_tools,
wrap_tool_call=wrap_tool_call_wrapper,
awrap_tool_call=awrap_tool_call_wrapper,
Expand Down Expand Up @@ -1491,7 +1491,7 @@ def model_to_model(

def _make_tools_to_model_edge(
*,
tool_node: _ToolNode,
tool_node: ToolNode,
model_destination: str,
structured_output_tools: dict[str, OutputToolBinding],
end_destination: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from langgraph.runtime import Runtime
from langgraph.types import Command

from langchain.tools.tool_node import ToolCallRequest
from langchain.agents.middleware.types import ToolCallRequest

LOGGER = logging.getLogger(__name__)
_DONE_MARKER_PREFIX = "__LC_SHELL_DONE__"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

from langgraph.types import Command

from langchain.agents.middleware.types import ToolCallRequest
from langchain.tools import BaseTool
from langchain.tools.tool_node import ToolCallRequest


class LLMToolEmulator(AgentMiddleware):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

from langgraph.types import Command

from langchain.agents.middleware.types import ToolCallRequest
from langchain.tools import BaseTool
from langchain.tools.tool_node import ToolCallRequest


class ToolRetryMiddleware(AgentMiddleware):
Expand Down
5 changes: 3 additions & 2 deletions libs/langchain_v1/langchain/agents/middleware/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
if TYPE_CHECKING:
from collections.abc import Awaitable

from langchain.tools.tool_node import ToolCallRequest

# Needed as top level import for Pydantic schema generation on AgentState
from typing import TypeAlias

from langchain_core.messages import AIMessage, AnyMessage, BaseMessage, ToolMessage # noqa: TC002
from langgraph.channels.ephemeral_value import EphemeralValue
from langgraph.graph.message import add_messages
from langgraph.prebuilt.tool_node import ToolCallRequest, ToolCallWrapper
from langgraph.types import Command # noqa: TC002
from langgraph.typing import ContextT
from typing_extensions import NotRequired, Required, TypedDict, TypeVar, Unpack
Expand All @@ -45,6 +44,8 @@
"ModelRequest",
"ModelResponse",
"OmitFromSchema",
"ToolCallRequest",
"ToolCallWrapper",
"after_agent",
"after_model",
"before_agent",
Expand Down
Loading