fix(agent): keep Nous GPT-5 fallback on chat completions
This commit is contained in:
@@ -3065,6 +3065,10 @@ class AIAgent:
|
|||||||
) -> bool:
|
) -> bool:
|
||||||
"""Return True when this provider/model pair should use Responses API."""
|
"""Return True when this provider/model pair should use Responses API."""
|
||||||
normalized_provider = (provider or "").strip().lower()
|
normalized_provider = (provider or "").strip().lower()
|
||||||
|
# Nous serves GPT-5.x models via its OpenAI-compatible chat
|
||||||
|
# completions endpoint; its /v1/responses endpoint returns 404.
|
||||||
|
if normalized_provider == "nous":
|
||||||
|
return False
|
||||||
if normalized_provider == "copilot":
|
if normalized_provider == "copilot":
|
||||||
try:
|
try:
|
||||||
from hermes_cli.models import _should_use_copilot_responses_api
|
from hermes_cli.models import _should_use_copilot_responses_api
|
||||||
|
|||||||
@@ -3729,8 +3729,8 @@ class TestMaxTokensParam:
|
|||||||
assert result == {"max_completion_tokens": 4096}
|
assert result == {"max_completion_tokens": 4096}
|
||||||
|
|
||||||
|
|
||||||
class TestAzureOpenAIRouting:
|
class TestGpt5ApiModeRouting:
|
||||||
"""Verify Azure OpenAI endpoints stay on chat_completions for gpt-5.x."""
|
"""Verify provider-specific GPT-5 API-mode routing."""
|
||||||
|
|
||||||
def test_azure_gpt5_stays_on_chat_completions(self, agent):
|
def test_azure_gpt5_stays_on_chat_completions(self, agent):
|
||||||
"""Azure serves gpt-5.x on /chat/completions — must not upgrade to codex_responses."""
|
"""Azure serves gpt-5.x on /chat/completions — must not upgrade to codex_responses."""
|
||||||
@@ -3769,6 +3769,25 @@ class TestAzureOpenAIRouting:
|
|||||||
agent.api_mode = "codex_responses"
|
agent.api_mode = "codex_responses"
|
||||||
assert agent.api_mode == "codex_responses"
|
assert agent.api_mode == "codex_responses"
|
||||||
|
|
||||||
|
def test_nous_gpt5_stays_on_chat_completions(self, agent):
|
||||||
|
"""Nous serves gpt-5.x on /chat/completions — must not upgrade to codex_responses."""
|
||||||
|
agent.provider = "nous"
|
||||||
|
agent.base_url = "https://inference-api.nousresearch.com/v1"
|
||||||
|
agent.api_mode = "chat_completions"
|
||||||
|
agent.model = "openai/gpt-5.5"
|
||||||
|
if (
|
||||||
|
agent.api_mode == "chat_completions"
|
||||||
|
and not agent._is_azure_openai_url()
|
||||||
|
and (
|
||||||
|
agent._is_direct_openai_url()
|
||||||
|
or agent._provider_model_requires_responses_api(
|
||||||
|
agent.model, provider=agent.provider,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
):
|
||||||
|
agent.api_mode = "codex_responses"
|
||||||
|
assert agent.api_mode == "chat_completions"
|
||||||
|
|
||||||
def test_is_azure_openai_url_detection(self, agent):
|
def test_is_azure_openai_url_detection(self, agent):
|
||||||
assert agent._is_azure_openai_url("https://foo.openai.azure.com/openai/v1") is True
|
assert agent._is_azure_openai_url("https://foo.openai.azure.com/openai/v1") is True
|
||||||
assert agent._is_azure_openai_url("https://api.openai.com/v1") is False
|
assert agent._is_azure_openai_url("https://api.openai.com/v1") is False
|
||||||
|
|||||||
Reference in New Issue
Block a user