From d01490560688581eb5e458de78c8bd3d2f4dc3b6 Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Sun, 15 Nov 2026 11:12:19 -0500 Subject: [PATCH] fix(llm): send tools declared without a description --- src/llm/src/README.md | 3 +++ src/llm/src/google/mapper.lua | 2 +- src/llm/src/openai/mapper.lua | 2 +- src/llm/src/openai_compat/mapper.lua | 2 +- src/llm/test/google/mapper_test.lua | 11 +++++++++++ src/llm/test/openai/mapper_test.lua | 12 ++++++++++++ src/llm/test/openai_compat/mapper_test.lua | 12 ++++++++++++ 7 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/llm/src/README.md b/src/llm/src/README.md index 81079d0..674ab0d 100644 --- a/src/llm/src/README.md +++ b/src/llm/src/README.md @@ -380,6 +380,9 @@ if result.tool_calls and #result.tool_calls > 0 then end ``` +A tool needs a `name` and a `schema`; `description` is optional, and every driver sends a +tool without one with the description field omitted. + Tool calls with malformed JSON arguments retain the original string in `arguments` and `raw_arguments`, with the decoder diagnostic in `arguments_error`. These optional fields are absent on valid calls. Hosts must reject calls with `arguments_error` through their diff --git a/src/llm/src/google/mapper.lua b/src/llm/src/google/mapper.lua index dab9d7e..151cc35 100644 --- a/src/llm/src/google/mapper.lua +++ b/src/llm/src/google/mapper.lua @@ -261,7 +261,7 @@ function mapper.map_tools(contract_tools) local tools = {} for _, tool in ipairs(contract_tools) do - if tool.name and tool.description and tool.schema then + if tool.name and tool.schema then table.insert(tools, { name = tool.name, description = tool.description, diff --git a/src/llm/src/openai/mapper.lua b/src/llm/src/openai/mapper.lua index a4942ff..35c09e4 100644 --- a/src/llm/src/openai/mapper.lua +++ b/src/llm/src/openai/mapper.lua @@ -287,7 +287,7 @@ function openai_mapper.map_tools(contract_tools, opts) local tool_name_map = {} for _, tool in ipairs(contract_tools) do - if tool.name and tool.description and tool.schema then + if tool.name and tool.schema then table.insert(tools, { type = "function", name = tool.name, diff --git a/src/llm/src/openai_compat/mapper.lua b/src/llm/src/openai_compat/mapper.lua index b4c34b3..48cac39 100644 --- a/src/llm/src/openai_compat/mapper.lua +++ b/src/llm/src/openai_compat/mapper.lua @@ -446,7 +446,7 @@ function openai_mapper.map_tools(contract_tools) local tool_name_map = {} for _, tool in ipairs(contract_tools) do - if tool.name and tool.description and tool.schema then + if tool.name and tool.schema then table.insert(openai_tools, { type = "function", ["function"] = { diff --git a/src/llm/test/google/mapper_test.lua b/src/llm/test/google/mapper_test.lua index c4704ee..c0834a6 100644 --- a/src/llm/test/google/mapper_test.lua +++ b/src/llm/test/google/mapper_test.lua @@ -706,6 +706,17 @@ local function define_tests() tests.is_nil(google_tools) end) + it("should send a tool declared without a description", function() + local google_tools = mapper.map_tools({ + { name = "ping", schema = { type = "object", properties = {} } } + }) :: any + + tests.eq(#google_tools, 1) + tests.eq(google_tools[1].name, "ping") + tests.is_nil(google_tools[1].description) + tests.eq(google_tools[1].parameters.type, "object") + end) + it("should skip tools with missing required fields", function() local contract_tools = { { diff --git a/src/llm/test/openai/mapper_test.lua b/src/llm/test/openai/mapper_test.lua index 2d642a9..a324591 100644 --- a/src/llm/test/openai/mapper_test.lua +++ b/src/llm/test/openai/mapper_test.lua @@ -666,6 +666,18 @@ local function define_tests() test.eq(tools[1].strict, true) end) + it("should send a tool declared without a description", function() + local tools, tool_map = openai_mapper.map_tools({ + { name = "ping", schema = { type = "object", properties = {} } } + }) + + test.eq(#tools, 1) + test.eq(tools[1].name, "ping") + test.is_nil(tools[1].description) + test.eq(tools[1].parameters.type, "object") + test.not_nil(tool_map["ping"]) + end) + it("should handle empty tools array", function() local tools, tool_map = openai_mapper.map_tools({}) diff --git a/src/llm/test/openai_compat/mapper_test.lua b/src/llm/test/openai_compat/mapper_test.lua index ef4694c..101bcfa 100644 --- a/src/llm/test/openai_compat/mapper_test.lua +++ b/src/llm/test/openai_compat/mapper_test.lua @@ -716,6 +716,18 @@ local function define_tests() test.is_nil(next(tool_map)) end) + it("should send a tool declared without a description", function() + local openai_tools, tool_map = openai_mapper.map_tools({ + { name = "ping", schema = { type = "object", properties = {} } } + }) + + test.eq(#openai_tools, 1) + test.eq(openai_tools[1]["function"].name, "ping") + test.is_nil(openai_tools[1]["function"].description) + test.eq(openai_tools[1]["function"].parameters.type, "object") + test.not_nil(tool_map["ping"]) + end) + it("should skip tools with missing required fields", function() local contract_tools = { {