fix(providers): preserve tool optionality in Responses requests

This commit is contained in:
chengyongru authored and chengyongru committed 2026-09-27 18:47:48 +08:00
1 parent f62e0da9f6
commit 932b06f0de
8 files changed
+127 -1

No files matched your search

@@ -998,3 +998,29 @@ async def test_codex_stream_surfaces_reasoning_summary(monkeypatch) -> None:
async def _append(target: list[str], value: str) -> None:
target.append(value)
async def test_codex_request_preserves_optional_tool_fields(monkeypatch):
_mock_codex_token(monkeypatch)
captured = {}
async def fake_request(_url, _headers, body, **_kwargs):
captured.update(body)
return provider_base.LLMResponse(content="ok")
monkeypatch.setattr("nanobot.providers.openai_codex_provider._request_codex", fake_request)
parameters = {
"type": "object",
"properties": {"query": {"type": "string"}},
"required": [],
}
response = await OpenAICodexProvider().chat(
[{"role": "user", "content": "Search issues"}],
tools=[{"type": "function", "function": {
"name": "list_issues", "parameters": parameters,
}}],
)
assert response.content == "ok"
assert captured["tools"][0]["strict"] is False
assert captured["tools"][0]["parameters"] == parameters