From 5776a6f3e395df6d479a76ae192182261ce8a1cc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Jun 2026 01:47:07 +0000 Subject: [PATCH 1/3] Initial plan From af41caff2be5771f26df53130d24cc9e06986f7f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Jun 2026 02:04:16 +0000 Subject: [PATCH 2/3] Fix: include schema guidance in empty-args error to prevent missing tool reports When an agent calls a safeoutputs tool with empty arguments (as a schema probe), the server now includes the required parameters and a usage example in the error response alongside the existing discovery-probe warning. This allows models like o4-mini (AOAI/Entra) that don't follow up with a tools/list call to immediately retry create_issue with correct arguments, instead of reporting it as a missing tool. Fixes smoke-copilot-aoai-entra failure: create_issue reported missing. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/mcp_server_core.cjs | 6 ++++-- actions/setup/js/mcp_server_core.test.cjs | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/actions/setup/js/mcp_server_core.cjs b/actions/setup/js/mcp_server_core.cjs index 370574379c2..7b707a21c4e 100644 --- a/actions/setup/js/mcp_server_core.cjs +++ b/actions/setup/js/mcp_server_core.cjs @@ -772,9 +772,10 @@ async function handleRequest(server, request, defaultHandler) { if (missing.length) { const hasRequiredFields = tool.inputSchema && Array.isArray(tool.inputSchema.required) && tool.inputSchema.required.length > 0; if (hasRequiredFields && Object.keys(args).length === 0) { + const schemaGuidance = generateEnhancedErrorMessage(tool.inputSchema.required, name, tool.inputSchema); throw { code: -32602, - message: `Empty arguments are not allowed — this tool is write-once, not a discovery probe. To inspect the schema, use the tools/list MCP method. To signal that no action is needed, call \`noop\` with a \`message\`.`, + message: `Empty arguments are not allowed — this tool is write-once, not a discovery probe. To inspect the schema, use the tools/list MCP method. To signal that no action is needed, call \`noop\` with a \`message\`.\n\n${schemaGuidance}`, }; } throw { @@ -941,10 +942,11 @@ async function handleMessage(server, req, defaultHandler) { if (missing.length) { const hasRequiredFields = tool.inputSchema && Array.isArray(tool.inputSchema.required) && tool.inputSchema.required.length > 0; if (hasRequiredFields && Object.keys(args).length === 0) { + const schemaGuidance = generateEnhancedErrorMessage(tool.inputSchema.required, name, tool.inputSchema); server.replyError( id, -32602, - `Empty arguments are not allowed — this tool is write-once, not a discovery probe. To inspect the schema, use the tools/list MCP method. To signal that no action is needed, call \`noop\` with a \`message\`.` + `Empty arguments are not allowed — this tool is write-once, not a discovery probe. To inspect the schema, use the tools/list MCP method. To signal that no action is needed, call \`noop\` with a \`message\`.\n\n${schemaGuidance}` ); return; } diff --git a/actions/setup/js/mcp_server_core.test.cjs b/actions/setup/js/mcp_server_core.test.cjs index 7f86c1529d4..c13bc70c3c4 100644 --- a/actions/setup/js/mcp_server_core.test.cjs +++ b/actions/setup/js/mcp_server_core.test.cjs @@ -354,6 +354,9 @@ describe("mcp_server_core.cjs", () => { expect(results[0].error.message).toContain("write-once, not a discovery probe"); expect(results[0].error.message).toContain("tools/list"); expect(results[0].error.message).toContain("noop"); + // Schema guidance should be included so the model can retry without calling tools/list + expect(results[0].error.message).toContain("Example:"); + expect(results[0].error.message).toContain("Required parameter"); }); it("should return enhanced error for partially-supplied but invalid required fields", async () => { From 4601b9004223b0870cf16cbb2bae0a207688479f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Jun 2026 03:29:25 +0000 Subject: [PATCH 3/3] test: add handleRequest probe-detection test for empty-args schema guidance Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/mcp_server_core.test.cjs | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/actions/setup/js/mcp_server_core.test.cjs b/actions/setup/js/mcp_server_core.test.cjs index c13bc70c3c4..e5819d785fc 100644 --- a/actions/setup/js/mcp_server_core.test.cjs +++ b/actions/setup/js/mcp_server_core.test.cjs @@ -571,6 +571,43 @@ describe("mcp_server_core.cjs", () => { expect(response.error.message).toContain("too short"); expect(response.error.message).toContain("20"); }); + + it("should return error for empty arguments object (probe detection) via handleRequest", async () => { + const { createServer, registerTool, handleRequest } = await import("./mcp_server_core.cjs"); + const server = createServer({ name: "test-server", version: "1.0.0" }); + + registerTool(server, { + name: "probe_tool", + description: "A tool to test probe detection", + inputSchema: { + type: "object", + properties: { input: { type: "string", description: "Some input" } }, + required: ["input"], + }, + handler: args => ({ + content: [{ type: "text", text: `received: ${args.input}` }], + }), + }); + + const response = await handleRequest(server, { + jsonrpc: "2.0", + id: 10, + method: "tools/call", + params: { + name: "probe_tool", + arguments: {}, // completely empty — probe attempt + }, + }); + + expect(response.error).toBeDefined(); + expect(response.error.code).toBe(-32602); + expect(response.error.message).toContain("write-once, not a discovery probe"); + expect(response.error.message).toContain("tools/list"); + expect(response.error.message).toContain("noop"); + // Schema guidance should be included so the model can retry without calling tools/list + expect(response.error.message).toContain("Example:"); + expect(response.error.message).toContain("Required parameter"); + }); }); describe("loadToolHandlers", () => {