[GH-ISSUE #3901] [BUG]: validFuncCall checks optional arguments #2485

Closed
opened 2026-02-22 18:29:54 -05:00 by yindo · 3 comments
Owner

Originally created by @fpytloun on GitHub (May 28, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3901

Originally assigned to: @shatfield4 on GitHub.

How are you running AnythingLLM?

Docker (local)

What happened?

I am using gitlab-mcp tool over streamable-http and it will result in this error without possibility to retrieve any details:

Invalid argument schema match

I tracked the issue down to validFuncCall and added some debug code:

    const props = Object.keys(foundFunc.parameters.properties);
    const fProps = Object.keys(functionCall.arguments);
    if (!this.compareArrays(props, fProps)) {
      return { valid: false, reason: `Invalid argument schema match. Expected properties: ${JSON.stringify(props)}, got: ${JSON.stringify(fProps)}` };
    }

which resulted in:

anythingllm  | [backend] info: [AgentLLM - gpt-4.1] Invalid function tool call: Invalid argument schema match.

Expected properties: ["assignee","author","confidential","created_after","created_before","due_date","iteration_id","labels","limit","milestone","project_id","search","state","updated_after","updated_before"],

got: ["project_id","assignee","state","updated_after"].

So it is verifying arguments passed to tool but ignores fact that some arguments are optional.

Are there known steps to reproduce?

No response

Originally created by @fpytloun on GitHub (May 28, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3901 Originally assigned to: @shatfield4 on GitHub. ### How are you running AnythingLLM? Docker (local) ### What happened? I am using gitlab-mcp tool over streamable-http and it will result in this error without possibility to retrieve any details: ``` Invalid argument schema match ``` I tracked the issue down to `validFuncCall` and added some debug code: ``` const props = Object.keys(foundFunc.parameters.properties); const fProps = Object.keys(functionCall.arguments); if (!this.compareArrays(props, fProps)) { return { valid: false, reason: `Invalid argument schema match. Expected properties: ${JSON.stringify(props)}, got: ${JSON.stringify(fProps)}` }; } ``` which resulted in: ``` anythingllm | [backend] info: [AgentLLM - gpt-4.1] Invalid function tool call: Invalid argument schema match. Expected properties: ["assignee","author","confidential","created_after","created_before","due_date","iteration_id","labels","limit","milestone","project_id","search","state","updated_after","updated_before"], got: ["project_id","assignee","state","updated_after"]. ``` So it is verifying arguments passed to tool but ignores fact that some arguments are optional. ### Are there known steps to reproduce? _No response_
yindo added the possible buginvestigating labels 2026-02-22 18:29:54 -05:00
yindo closed this issue 2026-02-22 18:29:54 -05:00
Author
Owner

@anytrace-ai-support-engineer-yc-s25 commented on GitHub (Jun 29, 2025):

Summary of the issue

This is a bug in server/utils/agents/aibitat/providers/helpers/untooled.js. validFuncCall currently treats all properties defined in a tool’s JSON-schema as required. Instead, it should specifically validate the existence of required properties for each plugin function.

Next steps for @fpytloun

None

Next steps for Multiplex-Labs

Fix the logic in vserver/utils/agents/aibitat/providers/helpers/untooled.js:validFuncCall(). Consider the fix:

-    const props = Object.keys(foundFunc.parameters.properties);
-    const fProps = Object.keys(functionCall.arguments);
-    if (!this.compareArrays(props, fProps)) {
-      return { valid: false, reason: "Invalid argument schema match." };
+    const schemaProps   = Object.keys(foundFunc.parameters.properties || {});
+    const requiredProps = foundFunc.required || [];  // Check for the required props only
+    const providedProps = Object.keys(functionCall.arguments);
+
+    // Check that all required properties are provided
+    for (const requiredProp of requiredProps) {
+      if (!providedProps.includes(requiredProp)) {
+        return {
+          valid: false,
+          reason: `Missing required argument: ${requiredProp}`
+        };
+      }
+    }
+
+    // Check that no unknown properties are provided
+    for (const providedProp of providedProps) {
+      if (!schemaProps.includes(providedProp)) {
+        return {
+          valid: false,
+          reason: `Unknown argument: ${providedProp}`
+        };
+      }
+    }

@timothycarambat @Mintplex-Labs

If you'd like Anytrace (YC S25) to keep investigating your support tickets, reach out to taira@anytrace.ai to discuss how we can keep supporting your team!

@anytrace-ai-support-engineer-yc-s25 commented on GitHub (Jun 29, 2025): ### Summary of the issue This is a bug in `server/utils/agents/aibitat/providers/helpers/untooled.js`. `validFuncCall` currently treats all properties defined in a tool’s JSON-schema as required. Instead, it should specifically validate the existence of [`required` properties for each plugin function](https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/agents/aibitat/plugins/rechart.js#L55). ### Next steps for @fpytloun None ### Next steps for Multiplex-Labs Fix the logic in `vserver/utils/agents/aibitat/providers/helpers/untooled.js:validFuncCall()`. Consider the fix: ``` - const props = Object.keys(foundFunc.parameters.properties); - const fProps = Object.keys(functionCall.arguments); - if (!this.compareArrays(props, fProps)) { - return { valid: false, reason: "Invalid argument schema match." }; + const schemaProps = Object.keys(foundFunc.parameters.properties || {}); + const requiredProps = foundFunc.required || []; // Check for the required props only + const providedProps = Object.keys(functionCall.arguments); + + // Check that all required properties are provided + for (const requiredProp of requiredProps) { + if (!providedProps.includes(requiredProp)) { + return { + valid: false, + reason: `Missing required argument: ${requiredProp}` + }; + } + } + + // Check that no unknown properties are provided + for (const providedProp of providedProps) { + if (!schemaProps.includes(providedProp)) { + return { + valid: false, + reason: `Unknown argument: ${providedProp}` + }; + } + } ``` ### @timothycarambat @Mintplex-Labs If you'd like Anytrace (YC S25) to keep investigating your support tickets, reach out to taira@anytrace.ai to discuss how we can keep supporting your team!
Author
Owner

@IceKickr commented on GitHub (Jul 7, 2025):

I believe I'm hitting the same issue w/ AWS' cloudwatch-mcp-server, execute_log_insights_query tool

@IceKickr commented on GitHub (Jul 7, 2025): I believe I'm hitting the same issue w/ AWS' cloudwatch-mcp-server, execute_log_insights_query tool
Author
Owner

@andrea9293 commented on GitHub (Jul 30, 2025):

I think I'm having the exact same problem. I'm using Gemini 2.5 Pro and I also tried with gpt-4.1 with the same result.

[backend] info: [AgentLLM - gemini-2.5-flash] Invalid function tool call: Invalid argument schema match..
[backend] info: [AgentLLM - gemini-2.5-flash] Will assume chat completion without tool call inputs.

What I noticed is that LLM probably misreads the function signature to invoke.

This is my server configuration.

{
	"mcpServers": {
		"brave-search": {
			"command": "npx",
			"args": [
				"@modelcontextprotocol/server-brave-search"
			],
			"env": {
				"BRAVE_API_KEY": "XXXXXXX"
			}
		},
		"time": {
			"command": "uvx",
			"args": [
				"mcp-server-time",
				"--local-timezone=Europe/Rome"
			]
		},
		"sequential-thinking": {
			"command": "/usr/bin/npx",
			"args": [
				"@modelcontextprotocol/server-sequential-thinking"
			]
		}
	}
}

This is the answer to what tools LLM has available.

Image

If you notice, it concatenated the server ID with the function name, but only for servers configured with npx (which are also the only ones causing the problem). For UVX servers, everything works fine.

brave-search-brave_web_search: To perform a general web search.
brave-search-brave_local_search: To search for local businesses and places.
time-get_current_time: To get the current time in a specific timezone. // it's time uvx server
time-convert_time: To convert time between timezones. // it's time uvx server
sequential-thinking-sequentialthinking: A detailed tool for dynamic and reflective problem-solving through thoughts.

I should add that from the agent skill screen, the functions and their descriptions work. The problem is only with the invocation via LLM.

@andrea9293 commented on GitHub (Jul 30, 2025): I think I'm having the exact same problem. I'm using Gemini 2.5 Pro and I also tried with gpt-4.1 with the same result. ``` [backend] info: [AgentLLM - gemini-2.5-flash] Invalid function tool call: Invalid argument schema match.. [backend] info: [AgentLLM - gemini-2.5-flash] Will assume chat completion without tool call inputs. ``` What I noticed is that LLM probably misreads the function signature to invoke. This is my server configuration. ``` { "mcpServers": { "brave-search": { "command": "npx", "args": [ "@modelcontextprotocol/server-brave-search" ], "env": { "BRAVE_API_KEY": "XXXXXXX" } }, "time": { "command": "uvx", "args": [ "mcp-server-time", "--local-timezone=Europe/Rome" ] }, "sequential-thinking": { "command": "/usr/bin/npx", "args": [ "@modelcontextprotocol/server-sequential-thinking" ] } } } ``` This is the answer to what tools LLM has available. <img width="567" height="608" alt="Image" src="https://github.com/user-attachments/assets/1af11a12-5069-4d8d-873c-1e50a94ebf0a" /> If you notice, it concatenated the server ID with the function name, but only for servers configured with npx (which are also the only ones causing the problem). For UVX servers, everything works fine. ``` brave-search-brave_web_search: To perform a general web search. brave-search-brave_local_search: To search for local businesses and places. time-get_current_time: To get the current time in a specific timezone. // it's time uvx server time-convert_time: To convert time between timezones. // it's time uvx server sequential-thinking-sequentialthinking: A detailed tool for dynamic and reflective problem-solving through thoughts. ``` I should add that from the agent skill screen, the functions and their descriptions work. The problem is only with the invocation via LLM.
yindo changed title from [BUG]: validFuncCall checks optional arguments to [GH-ISSUE #3901] [BUG]: validFuncCall checks optional arguments 2026-06-05 14:46:50 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2485