Skip to content

The agent engineering platform.

fix(core): exclude injected args from tool schema (#34582)

Mohan Kumar S13cfdf16763c
diff --git a/libs/core/langchain_core/tools/base.py b/libs/core/langchain_core/tools/base.py
index 5d86a4cf3a..983d5ab5a6 100644
--- a/libs/core/langchain_core/tools/base.py
+++ b/libs/core/langchain_core/tools/base.py
@@ -566,8 +566,11 @@ class ChildTool(BaseTool):
elif self.args_schema and issubclass(self.args_schema, BaseModelV1):
json_schema = self.args_schema.schema()
else:
- input_schema = self.get_input_schema()
- json_schema = input_schema.model_json_schema()
+ input_schema = self.tool_call_schema
+ if isinstance(input_schema, dict):
+ json_schema = input_schema
+ else:
+ json_schema = input_schema.model_json_schema()
return cast("dict", json_schema["properties"])
@property
diff --git a/libs/langchain_v1/tests/unit_tests/agents/test_injected_runtime_create_agent.py b/libs/langchain_v1/tests/unit_tests/agents/test_injected_runtime_create_agent.py
index 2be8d92306..96adf0c110 100644
--- a/libs/langchain_v1/tests/unit_tests/agents/test_injected_runtime_create_agent.py
+++ b/libs/langchain_v1/tests/unit_tests/agents/test_injected_runtime_create_agent.py
@@ -46,6 +46,8 @@ def test_tool_runtime_basic_injection() -> None:
injected_data["stream_writer"] = runtime.stream_writer
return f"Processed {x}"
+ assert runtime_tool.args
+
agent = create_agent(
model=FakeToolCallingModel(
tool_calls=[