Skip to content
Open
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
13 changes: 10 additions & 3 deletions libs/core/langchain_core/tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,10 +952,14 @@ def run(
tool_args, tool_kwargs = self._to_args_and_kwargs(
tool_input, tool_call_id
)
if signature(self._run).parameters.get("run_manager"):
run_parameters = signature(self._run).parameters
if run_parameters.get("run_manager"):
tool_kwargs |= {"run_manager": run_manager}
if config_param := _get_runnable_config_param(self._run):
tool_kwargs |= {config_param: config}
for key, value in kwargs.items():
if key in run_parameters and key not in tool_kwargs:
tool_kwargs[key] = value
response = context.run(self._run, *tool_args, **tool_kwargs)
if self.response_format == "content_and_artifact":
msg = (
Expand Down Expand Up @@ -1080,11 +1084,14 @@ async def arun(
func_to_check = (
self._run if self.__class__._arun is BaseTool._arun else self._arun # noqa: SLF001
)
if signature(func_to_check).parameters.get("run_manager"):
run_parameters = signature(func_to_check).parameters
if run_parameters.get("run_manager"):
tool_kwargs["run_manager"] = run_manager
if config_param := _get_runnable_config_param(func_to_check):
tool_kwargs[config_param] = config

for key, value in kwargs.items():
if key in run_parameters and key not in tool_kwargs:
tool_kwargs[key] = value
coro = self._arun(*tool_args, **tool_kwargs)
response = await coro_with_context(coro, context)
if self.response_format == "content_and_artifact":
Expand Down
Loading