Skip to content

Commit f6fc823

Browse files
committed
fix(providers): address Codex review on PR #67
Two P2 issues caught during PR #67 review (and surfaced by tests that landed on main after this branch forked). 1. **OpenAI**: stop auto-injecting ``max_tokens`` / ``temperature`` into the default kwargs. Two new tests on main (``test_payload_quirk_default_no_rewrite`` / ``test_payload_quirk_no_max_completion_tokens_noop``) assert that the provider does not stamp ``max_tokens`` on the payload — the caller is responsible via ``on_payload`` or the ``max_completion_tokens_alias`` quirk. The unconditional default also caused new-API providers (those requiring ``max_completion_tokens``) to reject requests that contained both limit fields. 2. **Anthropic**: skip ``temperature`` when extended thinking is on. Anthropic disallows temperature modifications with thinking; the previous unconditional default made any reasoning-enabled request fail. See: https://platform.claude.com/docs/en/build-with-claude/extended-thinking#feature-compatibility All 499 cubepi tests pass; cubebox cubepi+OpenAI-compat E2E still green.
1 parent 6bb2303 commit f6fc823

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

cubepi/providers/anthropic.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,14 @@ async def stream(
107107
"model": model.id,
108108
"messages": api_messages,
109109
"max_tokens": max_tokens,
110-
"temperature": model.temperature,
111110
}
111+
# Anthropic disallows temperature modifications when extended
112+
# thinking is enabled — see
113+
# https://platform.claude.com/docs/en/build-with-claude/extended-thinking#feature-compatibility
114+
# The provider request will fail with thinking on if we send a
115+
# non-default temperature, so skip the field unless thinking is off.
116+
if thinking == "off":
117+
kwargs["temperature"] = model.temperature
112118
if system_prompt:
113119
if cache_control and self._cache_policy.mark_system():
114120
kwargs["system"] = [

cubepi/providers/openai.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ async def stream(
7777
"model": model.id,
7878
"messages": api_messages,
7979
"stream": True,
80-
"max_tokens": model.max_tokens,
81-
"temperature": model.temperature,
8280
}
8381
if tools:
8482
kwargs["tools"] = [self._convert_tool(t) for t in tools]

0 commit comments

Comments
 (0)