fix: use max_completion_tokens for GitHub Copilot
This commit is contained in:
@@ -57,6 +57,18 @@ def codex_auth_dir(tmp_path, monkeypatch):
|
||||
return codex_dir
|
||||
|
||||
|
||||
class TestAuxiliaryMaxTokensParam:
|
||||
def test_uses_max_completion_tokens_for_github_copilot_custom_base(self):
|
||||
with patch("agent.auxiliary_client._resolve_custom_runtime", return_value=("https://api.githubcopilot.com", "key", None)), \
|
||||
patch("agent.auxiliary_client._read_nous_auth", return_value=None):
|
||||
assert auxiliary_max_tokens_param(2048) == {"max_completion_tokens": 2048}
|
||||
|
||||
def test_uses_max_completion_tokens_for_github_copilot_custom_base_path(self):
|
||||
with patch("agent.auxiliary_client._resolve_custom_runtime", return_value=("https://api.githubcopilot.com/chat/completions", "key", None)), \
|
||||
patch("agent.auxiliary_client._read_nous_auth", return_value=None):
|
||||
assert auxiliary_max_tokens_param(2048) == {"max_completion_tokens": 2048}
|
||||
|
||||
|
||||
class TestNormalizeAuxProvider:
|
||||
def test_maps_github_copilot_aliases(self):
|
||||
assert _normalize_aux_provider("github") == "copilot"
|
||||
|
||||
@@ -3666,6 +3666,18 @@ class TestMaxTokensParam:
|
||||
result = agent._max_tokens_param(4096)
|
||||
assert result == {"max_completion_tokens": 4096}
|
||||
|
||||
def test_returns_max_completion_tokens_for_github_copilot(self, agent):
|
||||
"""GitHub Copilot's OpenAI-compatible API rejects max_tokens for newer models."""
|
||||
agent.base_url = "https://api.githubcopilot.com"
|
||||
result = agent._max_tokens_param(4096)
|
||||
assert result == {"max_completion_tokens": 4096}
|
||||
|
||||
def test_returns_max_completion_tokens_for_github_copilot_path(self, agent):
|
||||
"""Detect Copilot by hostname even when the configured URL includes a path."""
|
||||
agent.base_url = "https://api.githubcopilot.com/chat/completions"
|
||||
result = agent._max_tokens_param(4096)
|
||||
assert result == {"max_completion_tokens": 4096}
|
||||
|
||||
|
||||
class TestAzureOpenAIRouting:
|
||||
"""Verify Azure OpenAI endpoints stay on chat_completions for gpt-5.x."""
|
||||
|
||||
Reference in New Issue
Block a user