fix(tools): forward explicit nulls through the LangChain adapter
What
StackOneTool.to_langchain() no longer drops None arguments in _run. The LangChain adapter now forwards exactly what the model sent, the same as to_pydantic_ai_tool already does.
Why
The filter was added in #199, when args_schema was a pydantic model: BaseTool then filled every unsupplied optional with None, so dropping None was the only way to tell "omitted" from "sent". Since the toolset became MCP-only, args_schema is the served JSON Schema dict. With a dict schema BaseTool passes the tool-call args through untouched, so an omitted optional is already absent. The filter now only removes something real: a null the model sent on purpose (for example to clear a nullable field), which the server never sees.
Probe against the locked langchain-core (1.6.3):
| Model sent | _run received before | _run receives now |
|---|---|---|
{"path_id": "x"} | {"path_id": "x"} | {"path_id": "x"} |
{"path_id": "x", "body_after": null} | {"path_id": "x"} | {"path_id": "x", "body_after": null} |
Risk
A caller that relied on LangChain stripping explicit nulls will now send them. Header arguments are unaffected: a null header value is still dropped by the header sanitiser before the call.
How verified
- Replaced the old test (which asserted the drop) with a parametrized
test_langchain_forwards_the_model_arguments_as_sentthat invokes the converted tool with a real tool call; the null case fails onmainand passes here. uv run ruff check .,uv run ruff format --check .,uv run ty check stackone_ai examples,uv run pytest -q: 872 passed.
Gates (head c67101b)
- Forge: ran, slop meter +17 -10, no findings.
- Security scan: ran, traced
Nonethrough the nested and flat header sanitising paths; nulls are dropped there, other arguments were already forwarded verbatim. - Codex security review: ran, no findings.
- /security-review: ran on the same scope, no findings.
Requested by guillaume@stackone.com in Slack (repo audit thread)
š¤ Generated with Claude Code
Summary by cubic
Makes the LangChain adapter forward explicit nulls to the tool call instead of dropping them, matching what to_pydantic_ai_tool already does. Previously every None argument was filtered because a pydantic args schema materialised unsupplied optionals as None; now the schema is a JSON Schema dict, so BaseTool passes the tool-call arguments through untouched ā an omitted optional stays absent, and a null the model sent on purpose reaches the server.
- Replaces the old test (which asserted the drop) with parametrized tests invoking the converted tool with a real tool call; the null case fails on
mainand passes here.
Risk
- Callers that relied on LangChain stripping explicit nulls will now send them.
- Header arguments are unaffected: a
nullheader value is still dropped by the header sanitiser before the call.