Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)
Python
Omit tool_choice when a request has no tools (#1805)
rodricksz4h534e7fa564dbf
diff --git a/pyproject.toml b/pyproject.tomlindex 1882d1d5..06c104ad 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "hatchling.build"[project]name = "free-claude-code"-version = "6.2.35"+version = "6.2.36"description = "Local proxy connecting coding agents to OpenAI-compatible AI providers"readme = "README.md"requires-python = ">=3.14.0"diff --git a/src/free_claude_code/core/anthropic/conversion.py b/src/free_claude_code/core/anthropic/conversion.pyindex 0091fe8b..528486ad 100644--- a/src/free_claude_code/core/anthropic/conversion.py+++ b/src/free_claude_code/core/anthropic/conversion.py@@ -53,12 +53,17 @@ def resolve_anthropic_tool_choice(tools: list[Any] | None,tool_choice: dict[str, Any] | None,) -> dict[str, Any] | None:- """Materialize Anthropic's automatic choice when tools are available."""+ """Materialize Anthropic's automatic choice when tools are available.++ A choice with no tools has nothing to act on, so it is dropped rather than+ forwarded. Gemini rejects the whole request otherwise, with "Function calling+ config is set without function_declarations".+ """+ if not tools:+ return Noneif tool_choice is not None:return tool_choice- if tools:- return {"type": "auto"}- return None+ return {"type": "auto"}def _reasoning_replay_field(mode: ReasoningReplayMode) -> str | None:diff --git a/tests/core/openai_responses/test_provider_input.py b/tests/core/openai_responses/test_provider_input.pyindex 2f1a05c9..3d4e0b4c 100644--- a/tests/core/openai_responses/test_provider_input.py+++ b/tests/core/openai_responses/test_provider_input.py@@ -311,6 +311,29 @@ def test_build_responses_provider_request_omits_choice_without_tools() -> None:assert "tool_choice" not in body[email protected]("choice", ["auto", "any", "none"])+def test_build_responses_provider_request_omits_explicit_choice_without_tools(+ choice: str,+) -> None:+ # An explicit choice must not survive either: "any" would otherwise become+ # "required", demanding a tool call when no tool exists.+ request = MessagesRequest.model_validate(+ {+ "model": "gpt-test",+ "messages": [{"role": "user", "content": "Hello"}],+ "tool_choice": {"type": choice},+ }+ )++ body = build_responses_provider_request(+ request,+ reasoning=ReasoningPolicy.off(),+ )++ assert "tools" not in body+ assert "tool_choice" not in body++def test_build_responses_provider_request_uses_resolved_reasoning_policy() -> None:request = MessagesRequest.model_validate({diff --git a/tests/providers/test_deepseek.py b/tests/providers/test_deepseek.pyindex 593cec26..ae03d119 100644--- a/tests/providers/test_deepseek.py+++ b/tests/providers/test_deepseek.py@@ -323,6 +323,7 @@ def test_build_request_body_tool_choice_keeps_thinking(deepseek_provider):"model": "m","messages": [{"role": "user", "content": "x"}],"tool_choice": {"type": "auto"},+ "tools": [{"name": "Read", "input_schema": {"type": "object"}}],"thinking": {"type": "enabled", "budget_tokens": 2000},})diff --git a/tests/providers/test_gemini.py b/tests/providers/test_gemini.pyindex 3606b463..cfa342d9 100644--- a/tests/providers/test_gemini.py+++ b/tests/providers/test_gemini.py@@ -233,6 +233,33 @@ def test_build_request_body_strips_unsupported_metadata_key(gemini_provider):assert "metadata" not in wire_json[email protected]("choice", ["auto", "any", "none"])+def test_build_request_body_omits_tool_choice_without_tools(gemini_provider, choice):+ """Regression for #565: Gemini rejects the whole request with "Function+ calling config is set without function_declarations" when a tool choice+ reaches it with no tools to choose from.+ """+ req = make_request(tool_choice={"type": choice})++ body = gemini_provider._chat._build_request_body(req, reasoning=reasoning_for(req))+ wire_json = _simulate_openai_sdk_wire_json(body)++ assert "tools" not in wire_json+ assert "tool_choice" not in wire_json+++def test_build_request_body_keeps_tool_choice_with_tools(gemini_provider):+ req = make_request(+ tool_choice={"type": "auto"},+ tools=[{"name": "Read", "input_schema": {"type": "object"}}],+ )++ body = gemini_provider._chat._build_request_body(req, reasoning=reasoning_for(req))++ assert body["tool_choice"] == "auto"+ assert [tool["function"]["name"] for tool in body["tools"]] == ["Read"]++def test_build_request_body_merges_caller_nested_google(gemini_provider):req = make_request(thinking=None,diff --git a/uv.lock b/uv.lockindex 2615f738..2a4d38f2 100644--- a/uv.lock+++ b/uv.lock@@ -599,7 +599,7 @@ wheels = [[[package]]name = "free-claude-code"-version = "6.2.35"+version = "6.2.36"source = { editable = "." }dependencies = [{ name = "aiohttp" },