Skip to content

Commit e9afc65

Browse files
jedardenclaude
andcommitted
fix: Add additionalProperties:false to tool schemas for OpenAI Responses API
CRITICAL FIX for "Invalid tool parameters" errors with spawned Task agents. The OpenAI Responses API REQUIRES `additionalProperties: false` in tool parameter schemas. Without this field, the API returns: "Invalid schema for function '...': In context=(), 'additionalProperties' is required to be supplied and to be false" This caused Task agents spawned by Claude Code to fail immediately with "0 tool uses" and "Invalid tool parameters" errors, even though strict: false was already set. Changes: - Add additionalProperties: false to all object schemas in cleanupSchemaMapForResponses - Add dedicated test TestTransformToolsToResponses_AdditionalPropertiesFalse - Bump version to v0.42.3 This fix completes the tool schema translation for OpenAI Responses API compatibility. References: - github/github-mcp-server#376 - https://community.openai.com/t/schema-additionalproperties-must-be-false-when-strict-is-true/929996 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 6fb4761 commit e9afc65

5 files changed

Lines changed: 68 additions & 3 deletions

File tree

‎cmd/clasp/main.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
)
2727

2828
var (
29-
version = "v0.42.2"
29+
version = "v0.42.3"
3030
)
3131

3232
func main() {

‎internal/translator/responses_request.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ func cleanupSchemaForResponses(schema interface{}) interface{} {
301301

302302
// cleanupSchemaMapForResponses recursively cleans up schema properties for Responses API.
303303
// Key fix: Only include truly required parameters (those without defaults and not nullable).
304+
// Also adds "additionalProperties": false which is REQUIRED by OpenAI Responses API.
304305
func cleanupSchemaMapForResponses(schema map[string]interface{}) {
305306
// Remove unsupported format types
306307
if format, ok := schema["format"].(string); ok {
@@ -314,6 +315,14 @@ func cleanupSchemaMapForResponses(schema map[string]interface{}) {
314315
// validation failures when optional parameters are missing.
315316
delete(schema, "strict")
316317

318+
// CRITICAL: Add additionalProperties: false at top level of object schemas
319+
// OpenAI Responses API REQUIRES this even when strict: false is set.
320+
// Without this, you get: "Invalid schema for function '...': 'additionalProperties'
321+
// is required to be supplied and to be false"
322+
if schemaType, ok := schema["type"].(string); ok && schemaType == "object" {
323+
schema["additionalProperties"] = false
324+
}
325+
317326
// Process properties and fix required array
318327
if props, ok := schema["properties"].(map[string]interface{}); ok {
319328
// Identify truly required parameters

‎internal/translator/responses_request_test.go‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,3 +958,59 @@ func TestTransformToolsToResponses_StrictModeFalse(t *testing.T) {
958958
jsonData, _ := json.MarshalIndent(tool, "", " ")
959959
t.Logf("Generated tool JSON:\n%s", string(jsonData))
960960
}
961+
962+
func TestTransformToolsToResponses_AdditionalPropertiesFalse(t *testing.T) {
963+
// Test that tools are created with additionalProperties: false
964+
// OpenAI Responses API REQUIRES this field even when strict: false is set.
965+
// Without it, you get: "Invalid schema for function '...': 'additionalProperties'
966+
// is required to be supplied and to be false"
967+
tools := []models.AnthropicTool{
968+
{
969+
Name: "Task",
970+
Description: "Launch a task agent",
971+
InputSchema: map[string]interface{}{
972+
"type": "object",
973+
"properties": map[string]interface{}{
974+
"description": map[string]interface{}{
975+
"type": "string",
976+
"description": "Task description",
977+
},
978+
"prompt": map[string]interface{}{
979+
"type": "string",
980+
"description": "The task for the agent to perform",
981+
},
982+
"subagent_type": map[string]interface{}{
983+
"type": "string",
984+
"description": "Type of specialized agent",
985+
},
986+
},
987+
"required": []interface{}{"description", "prompt", "subagent_type"},
988+
},
989+
},
990+
}
991+
992+
result := transformToolsToResponses(tools)
993+
994+
if len(result) != 1 {
995+
t.Fatalf("Expected 1 tool, got %d", len(result))
996+
}
997+
998+
tool := result[0]
999+
1000+
// Verify additionalProperties is false at top level
1001+
params, ok := tool.Parameters.(map[string]interface{})
1002+
if !ok {
1003+
t.Fatal("Tool.Parameters should be a map")
1004+
}
1005+
1006+
additionalProps, hasAdditional := params["additionalProperties"]
1007+
if !hasAdditional {
1008+
t.Error("Tool.Parameters should have additionalProperties field (required by OpenAI Responses API)")
1009+
} else if additionalProps != false {
1010+
t.Errorf("Tool.Parameters.additionalProperties should be false, got %v", additionalProps)
1011+
}
1012+
1013+
// Log for debugging
1014+
jsonData, _ := json.MarshalIndent(tool, "", " ")
1015+
t.Logf("Generated tool JSON with additionalProperties:\n%s", string(jsonData))
1016+
}

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "clasp-ai",
3-
"version": "0.42.2",
3+
"version": "0.42.3",
44
"description": "Claude Language Agent Super Proxy - Translate Claude/Anthropic API calls to OpenAI-compatible endpoints",
55
"author": "jedarden",
66
"license": "MIT",

‎scripts/install.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const path = require('path');
1212
const { execSync } = require('child_process');
1313
const os = require('os');
1414

15-
const VERSION = '0.42.1';
15+
const VERSION = '0.42.3';
1616
const REPO = 'jedarden/CLASP';
1717
const BINARY_NAME = 'clasp';
1818

0 commit comments

Comments
 (0)