fix(tools): add the native function schema for generate_image

generate_image existed in the prompt sections, the executor and the image_gen
MCP server, but not in FUNCTION_TOOL_SCHEMAS. API models are only sent schemas
from that list, so the tool selector could pick it and the schema filter would
drop it again — the model then improvised text-shaped calls it had no way to
make work.

The existing JSON fallback in function_call_to_tool_block already produces
content the executor parses, so no converter branch is needed. A required-args
entry is, though: without it a prompt-less call falls through to the line
parser and the whole JSON blob becomes the image prompt.

Fixes #5520

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
VykosMolt
2026-09-05 02:42:07 +02:00
co-authored by Claude
parent affaee1e66
commit dbfc96b8f3
2 changed files with 81 additions and 0 deletions
+20
View File
@@ -26,6 +26,9 @@ _REQUIRED_NATIVE_TOOL_ARGS = {
"write_file": ("path",),
"edit_file": ("path",),
"apply_patch": ("patch_text", "patchText", "patch"),
# Without this, a prompt-less call falls through to the line parser in
# tool_execution and the whole JSON blob becomes the image prompt.
"generate_image": ("prompt",),
}
# ---------------------------------------------------------------------------
@@ -1030,6 +1033,23 @@ FUNCTION_TOOL_SCHEMAS = [
}
}
},
{
"type": "function",
"function": {
"name": "generate_image",
"description": "Generate an image from a text prompt. Art, illustrations, photos.",
"parameters": {
"type": "object",
"properties": {
"prompt": {"type": "string", "description": "Image description prompt"},
"model": {"type": "string", "description": "Model name (auto-detects if omitted)"},
"size": {"type": "string", "description": "Image size (default 1024x1024)"},
"quality": {"type": "string", "description": "Quality: low, medium, high, auto (default medium)"},
},
"required": ["prompt"]
}
}
},
{
"type": "function",
"function": {