mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
fix: 补全 OpenAI 工具参数 schema 中缺失的 properties 字段
OpenAI API 要求 type=object 的 schema 节点必须声明 properties, 否则会拒绝请求。在 request_from_internal 出口处对工具参数 schema 进行深拷贝并递归补全缺失的空 properties,不影响内部表示。
This commit is contained in:
@@ -776,6 +776,21 @@ def test_openai_cli_request_from_internal_keeps_natural_insertion_order() -> Non
|
||||
assert list(out.keys())[:4] == ["model", "input", "max_output_tokens", "tools"]
|
||||
|
||||
|
||||
def test_openai_cli_request_from_internal_fixes_empty_object_tool_parameters() -> None:
|
||||
normalizer = OpenAICliNormalizer()
|
||||
internal = normalizer.request_to_internal(
|
||||
{
|
||||
"model": "gpt-test",
|
||||
"input": [],
|
||||
"tools": [{"type": "function", "name": "read_file", "parameters": {"type": "object"}}],
|
||||
}
|
||||
)
|
||||
|
||||
out = normalizer.request_from_internal(internal)
|
||||
|
||||
assert out["tools"][0]["parameters"] == {"type": "object", "properties": {}}
|
||||
|
||||
|
||||
def test_claude_explicit_effort_preserved_in_openai_cli() -> None:
|
||||
reg = _make_registry_with_cli()
|
||||
|
||||
|
||||
@@ -258,6 +258,26 @@ def test_openai_request_from_internal_keeps_natural_insertion_order() -> None:
|
||||
assert list(out.keys())[:4] == ["model", "messages", "max_tokens", "tools"]
|
||||
|
||||
|
||||
def test_openai_request_from_internal_fixes_empty_object_tool_parameters() -> None:
|
||||
n = OpenAINormalizer()
|
||||
|
||||
req = {
|
||||
"model": "gpt-4o-mini",
|
||||
"messages": [{"role": "user", "content": "ping"}],
|
||||
"tools": [
|
||||
{
|
||||
"type": "function",
|
||||
"function": {"name": "noop", "parameters": {"type": "object"}},
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
internal = n.request_to_internal(req)
|
||||
out = n.request_from_internal(internal)
|
||||
|
||||
assert out["tools"][0]["function"]["parameters"] == {"type": "object", "properties": {}}
|
||||
|
||||
|
||||
def test_openai_request_content_image_and_unknown_drop() -> None:
|
||||
n = OpenAINormalizer()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user