From d14f240b3c943e83280ee83b4f8e6385f6a888d4 Mon Sep 17 00:00:00 2001 From: x x Date: Sat, 3 Oct 2026 17:14:30 +0800 Subject: [PATCH] fix(mcp): align OpenAI file parameter schema --- internal/mcp/server_test.go | 4 ++-- internal/tool/media/contract.go | 2 +- internal/tool/media/request.go | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/mcp/server_test.go b/internal/mcp/server_test.go index ba94b91e1..4ed0d47e2 100644 --- a/internal/mcp/server_test.go +++ b/internal/mcp/server_test.go @@ -98,8 +98,8 @@ func TestOpenAIFileMetadataMatchesDeclaredSchemas(t *testing.T) { if !ok { t.Fatalf("%s file input path %q missing from input schema", def.Name, path) } - if property["type"] != "string" || property["format"] != "binary" { - t.Fatalf("%s file input %q must be string/binary: %#v", def.Name, path, property) + if property["type"] != "object" || property["additionalProperties"] != true { + t.Fatalf("%s file input %q must be an open object: %#v", def.Name, path, property) } } if len(def.FileArgRewritePaths) > 0 { diff --git a/internal/tool/media/contract.go b/internal/tool/media/contract.go index fd03255a5..9507c6dd8 100644 --- a/internal/tool/media/contract.go +++ b/internal/tool/media/contract.go @@ -52,7 +52,7 @@ func InputSchema(name string) (map[string]any, bool) { } return schema, true case ToolFilePublish: - props["file"] = map[string]any{"type": "string", "format": "binary", "description": "Top-level file parameter. Connector runtimes should pass the mounted local path when available."} + props["file"] = toolcontract.OpenObject("Top-level connector file object. Connector runtimes may rewrite this object with mounted local-path metadata before the tool call reaches AgentDock.") props["path"] = stringProp("Local file or directory path visible to this AgentDock instance. Relative paths resolve from ~/AgentDock.") props["retention_seconds"] = boundedIntProp("Signed URL retention seconds. Zero uses the default 86400 and values are capped at 604800.", 0, int(publicartifacts.MaxRetention/time.Second)) default: diff --git a/internal/tool/media/request.go b/internal/tool/media/request.go index e4229f89b..b0d807a98 100644 --- a/internal/tool/media/request.go +++ b/internal/tool/media/request.go @@ -24,7 +24,8 @@ type ViewImageRequest struct { Crop *CropRequest `json:"crop,omitempty"` } -// FilePublishRequest.File 是 connector 文件重写产生的动态叶子;Path 是普通本地路径入口。 +// FilePublishRequest.File 是 connector 文件重写产生的动态对象;Path 是普通本地路径入口。 +// File 保持 any 以兼容不同 connector 注入的文件对象形状,以及旧客户端仍可能发送的路径字符串。 type FilePublishRequest struct { File any `json:"file,omitempty"` Path string `json:"path,omitempty"`