Skip to content

fix(agent_langchain, tool_mcp_client): reasoning-model agents silently drop zero-argument MCP tools - #1451

Closed
Pankajsharma99max wants to merge 2 commits into
rocketride-org:developfrom
Pankajsharma99max:fix/1404-mcp-zero-arg-tool-schema
Closed

Pankajsharma99max wants to merge 2 commits into
rocketride-org:developfrom
Pankajsharma99max:fix/1404-mcp-zero-arg-tool-schema

Conversation

@Pankajsharma99max

@Pankajsharma99max Pankajsharma99max commented Jul 3, 2026 •

Copy link
Copy Markdown

Fixes #1404

Two independent defects combined to cause reasoning-model agents (e.g. qwen/qwen3.6-27b on Groq) to silently drop zero-argument MCP tools:

  1. tool_mcp_client.IGlobal.list_namespaced_tools() exposed a tool's JSON schema under the key input_schema (snake_case), but the canonical ToolsBase.ToolDescriptor contract in packages/ai/src/ai/common/tools.py -- and every framework driver that reads it -- expects inputSchema (camelCase). The mismatch meant td.get('inputSchema') in agent_langchain/langchain.py always returned None for MCP-sourced tools, silently discarding the real schema before it ever reached the driver.
  2. agent_langchain.langchain._make_args_schema treated "no schema info at all" and "schema explicitly declares zero properties" as the same case, falling back to the permissive _ToolInput (which advertises a generic input field) for both. A genuinely zero-argument tool therefore looked to the model like it required an input argument -- which is what caused reasoning models to either skip the tool or call it with an argument the MCP server did not expect and rejected.

Fix

  • Correct the key mismatch (input_schema -> inputSchema) in IGlobal.list_namespaced_tools().
  • Give explicitly zero-argument tools a strict, field-free _NoArgsInput schema (rendered as {"type": "object", "properties": {}}) instead of conflating them with the "unknown schema" _ToolInput fallback. Tools with no schema info at all keep the permissive fallback so arbitrary args still get through.

Testing

  • Added nodes/test/agent_langchain/test_zero_arg_tool_schema.py and nodes/test/tool_mcp_client coverage (6 new tests) exercising both the key-rename and the schema-fallback split.
  • Verified (locally, by reverting the fix) that these tests fail against the pre-fix code with exactly the symptoms described in the issue, and pass after the fix.
  • ruff check / ruff format --diff clean on all changed files.

Summary by CodeRabbit

  • Bug Fixes

    • Tools that explicitly declare no parameters are now treated as true no-argument tools, preventing accidental generic input fields.
    • Namespaced tool input schemas are now surfaced under the expected inputSchema key for improved downstream compatibility.
  • Tests

    • Added regression tests covering zero-argument tool schema handling, correct schema key formatting, and validation for tools with real parameters.

…y drop zero-argument MCP tools

Fixes rocketride-org#1404

Two independent defects combined to cause this:

1. `tool_mcp_client.IGlobal.list_namespaced_tools()` exposed a tool's JSON
   schema under the key `input_schema` (snake_case), but the canonical
   `ToolsBase.ToolDescriptor` contract in `packages/ai/src/ai/common/tools.py`
   -- and every framework driver that reads it -- expects `inputSchema`
   (camelCase). The mismatch meant `td.get('inputSchema')` always returned
   `None` for MCP-sourced tools, silently discarding the real schema before
   it ever reached the driver.

2. `agent_langchain.langchain._make_args_schema` treated "no schema info at
   all" and "schema explicitly declares zero properties" as the same case,
   falling back to the permissive `_ToolInput` (which advertises a generic
   `input` field) for both. A genuinely zero-argument tool therefore looked
   to the model like it required an `input` argument -- which is what caused
   reasoning models to either skip the tool or call it with an argument the
   MCP server didn't expect and rejected.

Fix: correct the key mismatch, and give explicitly zero-argument tools a
strict, field-free `_NoArgsInput` schema (rendered as
`{"type":"object","properties":{}}`) instead of conflating them with the
"unknown schema" fallback.

Added regression tests covering both defects; verified they fail against
the pre-fix code and pass after the fix.
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor
🤖 Internal: Discord sync marker

Auto-managed by the Discord notification workflow. Stores the linked Discord message ID. Do not edit or delete.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR changes LangChain tool schema generation to treat explicit empty MCP tool schemas as strict no-argument models, fixes MCP tool descriptors to emit inputSchema, and adds regression tests for the key naming and schema-shape behavior.

Changes

Zero-argument tool schema handling

Layer / File(s) Summary
Strict no-args schema in LangChain tool builder
nodes/src/nodes/agent_langchain/langchain.py
Adds a strict _NoArgsInput Pydantic model and updates _make_args_schema to return it for tools with empty or non-dict properties, while keeping the permissive fallback for missing schema details.
Canonical inputSchema key in tool descriptor
nodes/src/nodes/tool_mcp_client/IGlobal.py
Changes list_namespaced_tools to emit the tool schema under the camelCase inputSchema key instead of input_schema.
Regression tests for zero-arg tool schema and key naming
nodes/test/agent_langchain/test_zero_arg_tool_schema.py
Adds test stubs, loaders, and test classes verifying the inputSchema key and strict or permissive args schema behavior for empty, real-parameter, and missing schemas.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
    participant MCP as IGlobal.list_namespaced_tools
    participant Agent as langchain._build_langchain_tools
    participant Schema as _make_args_schema

    MCP->>Agent: tool descriptor with inputSchema
    Agent->>Schema: derive args schema
    alt properties missing
        Schema-->>Agent: _ToolInput
    else properties empty or non-dict
        Schema-->>Agent: _NoArgsInput
    else properties present
        Schema-->>Agent: named fields
    end
Loading

Related Issues: #1404

Suggested labels: bug, tool-mcp-client, agent-langchain

Suggested reviewers: aryanshah-aparavi

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main fix for zero-argument MCP tools across agent_langchain and tool_mcp_client.
Linked Issues check ✅ Passed The changes match the issue by surfacing inputSchema correctly and treating explicit empty schemas as strict no-arg tools.
Out of Scope Changes check ✅ Passed The diff is limited to the schema fix and regression tests, with no unrelated changes evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@nodes/src/nodes/agent_langchain/langchain.py`:
- Around line 168-172: The schema handling in the langchain input parser is
treating a missing properties field as an empty no-args schema, which
misclassifies unconstrained object inputs. Update the logic in the input_schema
parsing path around the isinstance(input_schema, dict) check so it first tests
whether 'properties' is present in input_schema, and only returns _NoArgsInput
when an object schema explicitly declares an empty properties map. Keep the
existing _ToolInput fallback for schemas without properties and preserve the
current _NoArgsInput behavior only for explicitly empty object schemas.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 867e8c7b-8ab1-4e49-9a51-0fda6e01dbff

📥 Commits

Reviewing files that changed from the base of the PR and between 80c6654 and 16e24c9.

📒 Files selected for processing (3)
  • nodes/src/nodes/agent_langchain/langchain.py
  • nodes/src/nodes/tool_mcp_client/IGlobal.py
  • nodes/test/agent_langchain/test_zero_arg_tool_schema.py

Pankajsharma99max added a commit to Pankajsharma99max/rocketride-server that referenced this pull request Jul 3, 2026
Fixes rocketride-org#1404 -- reasoning-model agents silently drop zero-argument MCP tools.
See PR rocketride-org#1451: rocketride-org#1451
…args

Addresses review feedback on rocketride-org#1404 (PR rocketride-org#1451).

`input_schema.get('properties', {})` collapsed two different schemas into
the same case: `{"type": "object"}` (properties key absent -- an
unconstrained object shape) and `{"type": "object", "properties": {}}`
(properties key explicitly present and empty -- a genuine zero-argument
declaration). Both produced an empty dict from `.get(..., {})` and were
routed to the new strict `_NoArgsInput` schema, so a tool with an
unconstrained/unknown argument shape would incorrectly be told it takes no
arguments at all.

Now `'properties' not in input_schema` is checked explicitly and routed to
the permissive `_ToolInput` fallback (same as "no schema info at all"),
leaving `_NoArgsInput` for schemas that explicitly declare zero
properties.

Added a regression test for the missing-properties-key case; verified it
fails against the pre-fix logic and passes after.
Pankajsharma99max added a commit to Pankajsharma99max/rocketride-server that referenced this pull request Jul 3, 2026
Pulls in the CodeRabbit review fix for rocketride-org#1404 (missing-properties-key edge
case). See PR rocketride-org#1451: rocketride-org#1451
@Pankajsharma99max

Copy link
Copy Markdown
Author

Good catch -- fixed in the latest commit. input_schema.get('properties', {}) was collapsing {"type": "object"} (properties key absent, unconstrained shape) and {"type": "object", "properties": {}} (explicitly empty) into the same case. Now 'properties' not in input_schema routes to the permissive _ToolInput fallback, and only an explicitly empty properties gets the strict _NoArgsInput. Added a regression test for the missing-properties-key case (verified it fails against the prior logic and passes now).

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@nodes/src/nodes/agent_langchain/langchain.py`:
- Around line 173-179: The `get_tool_input_schema`-style logic in `langchain.py`
now correctly handles missing vs empty `properties`, but the `props` type check
still collapses malformed non-dict `properties` into `_NoArgsInput`. Update the
branch around `input_schema`, `properties`, and `props` so that only an explicit
empty dict returns `_NoArgsInput`, while a present-but-invalid `properties`
value falls back to `_ToolInput` like the missing-key case. Keep the existing
distinction intact in the same helper that selects between `_ToolInput` and
`_NoArgsInput`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: fc5866b5-d8bd-45c8-a736-824dbcf6aae3

📥 Commits

Reviewing files that changed from the base of the PR and between 16e24c9 and 7b3ef01.

📒 Files selected for processing (2)
  • nodes/src/nodes/agent_langchain/langchain.py
  • nodes/test/agent_langchain/test_zero_arg_tool_schema.py

Comment on lines 173 to +179
if not isinstance(input_schema, dict):
return _ToolInput
props = input_schema.get('properties', {})
if not isinstance(props, dict) or not props:
if 'properties' not in input_schema:
return _ToolInput
props = input_schema.get('properties')
if not isinstance(props, dict) or not props:
return _NoArgsInput

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Correctly fixes the missing-vs-empty properties bug.

This properly distinguishes {"type": "object"} (no properties key → _ToolInput fallback) from {"type": "object", "properties": {}} (explicit empty → _NoArgsInput), resolving the previously flagged collapse issue.

One residual edge case: Line 178 treats a properties key that is present but not a dict (malformed schema) the same as an explicitly empty object, returning _NoArgsInput. A malformed/non-dict properties isn't an explicit "no args" declaration — it's unknown/invalid schema shape, which should arguably fall back to the permissive _ToolInput like the "missing key" case above, rather than being forced into the strict no-args model.

🔧 Suggested refinement
-        props = input_schema.get('properties')
-        if not isinstance(props, dict) or not props:
+        props = input_schema.get('properties')
+        if not isinstance(props, dict):
+            return _ToolInput
+        if not props:
             return _NoArgsInput
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if not isinstance(input_schema, dict):
return _ToolInput
props = input_schema.get('properties', {})
if not isinstance(props, dict) or not props:
if 'properties' not in input_schema:
return _ToolInput
props = input_schema.get('properties')
if not isinstance(props, dict) or not props:
return _NoArgsInput
if not isinstance(input_schema, dict):
return _ToolInput
if 'properties' not in input_schema:
return _ToolInput
props = input_schema.get('properties')
if not isinstance(props, dict):
return _ToolInput
if not props:
return _NoArgsInput
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nodes/src/nodes/agent_langchain/langchain.py` around lines 173 - 179, The
`get_tool_input_schema`-style logic in `langchain.py` now correctly handles
missing vs empty `properties`, but the `props` type check still collapses
malformed non-dict `properties` into `_NoArgsInput`. Update the branch around
`input_schema`, `properties`, and `props` so that only an explicit empty dict
returns `_NoArgsInput`, while a present-but-invalid `properties` value falls
back to `_ToolInput` like the missing-key case. Keep the existing distinction
intact in the same helper that selects between `_ToolInput` and `_NoArgsInput`.

@charliegillet

Copy link
Copy Markdown
Contributor

Closing as superseded by #1491 (merged July 21), which resolved #1404. The inputSchema key fix here landed there verbatim (IGlobal.list_namespaced_tools now emits camelCase), and the zero-argument case is handled at the transport layer instead: all three MCP transports normalize empty or degenerate schemas via mcp_schema.normalize_tool_input_schema (an optional rr_no_args placeholder, stripped again before the real tools/call), with unit, integration, and agent-catalog tests. That means an explicitly empty properties object can no longer reach agent_langchain from an MCP tool, so the _NoArgsInput branch this PR adds would be dead code on develop, and the branch now conflicts. Thanks for the thorough diagnosis, the two-defect writeup here matched what got fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:nodes Python pipeline nodes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reasoning-model agents silently drop zero-argument MCP tools

2 participants