mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-24 16:54:43 +00:00
fix: use auxiliary_max_tokens_param for Copilot GPT-5 compat
Copilot review pointed out that hardcoding kwargs['max_tokens'] would 400 on models requiring max_completion_tokens (GPT-5 family, Copilot). The existing auxiliary_max_tokens_param() helper already selects the correct parameter name per model — use it instead of hardcoding. Test updated to parametrize expected_key so the Copilot gpt-5.5 case correctly asserts max_completion_tokens instead of max_tokens. Addresses Copilot review comments on both files.
This commit is contained in:
parent
32a4faa2d5
commit
3616ce006a
2 changed files with 15 additions and 9 deletions
|
|
@ -6839,7 +6839,10 @@ def _build_call_kwargs(
|
|||
or _is_nvidia_nim
|
||||
or _is_moa
|
||||
):
|
||||
kwargs["max_tokens"] = max_tokens
|
||||
# Use auxiliary_max_tokens_param() so models that require
|
||||
# max_completion_tokens (GPT-5 family, Copilot) get the right
|
||||
# parameter name instead of a hardcoded max_tokens that 400s.
|
||||
kwargs.update(auxiliary_max_tokens_param(max_tokens, model=model))
|
||||
|
||||
if tools:
|
||||
# Defensive dedup: providers like Google Vertex, Azure, and Bedrock
|
||||
|
|
|
|||
|
|
@ -659,22 +659,25 @@ class TestBuildCallKwargsMaxTokens:
|
|||
# ── MoA task should honor max_tokens on ALL providers (#reference_max_tokens) ──
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"provider,model,base_url",
|
||||
"provider,model,base_url,expected_key",
|
||||
[
|
||||
("zai", "glm-5.2", "https://api.z.ai/api/coding/paas/v4"),
|
||||
("openrouter", "deepseek/deepseek-v4-flash:nitro", "https://openrouter.ai/api/v1"),
|
||||
("copilot", "gpt-5.5", "https://api.githubcopilot.com"),
|
||||
("nous", "hermes-4", "https://inference-api.nousresearch.com/v1"),
|
||||
("zai", "glm-5.2", "https://api.z.ai/api/coding/paas/v4", "max_tokens"),
|
||||
("openrouter", "deepseek/deepseek-v4-flash:nitro", "https://openrouter.ai/api/v1", "max_tokens"),
|
||||
("copilot", "gpt-5.5", "https://api.githubcopilot.com", "max_completion_tokens"),
|
||||
("nous", "hermes-4", "https://inference-api.nousresearch.com/v1", "max_tokens"),
|
||||
],
|
||||
)
|
||||
def test_moa_task_sends_max_tokens_on_openai_compatible(self, provider, model, base_url):
|
||||
def test_moa_task_sends_max_tokens_on_openai_compatible(self, provider, model, base_url, expected_key):
|
||||
"""MoA reference/aggregator tasks must honor max_tokens regardless of provider.
|
||||
|
||||
The ``reference_max_tokens`` config option (PR #56756) caps advisor output
|
||||
to reduce turn latency. Before the fix, ``_build_call_kwargs`` silently
|
||||
dropped the value for OpenAI-compatible providers (PR #34845), so the cap
|
||||
never reached the API. With the ``task`` parameter threaded through,
|
||||
any task starting with ``moa_`` must include ``max_tokens`` in kwargs.
|
||||
any task starting with ``moa_`` must include the output cap in kwargs.
|
||||
|
||||
Models that require ``max_completion_tokens`` (GPT-5 family, Copilot)
|
||||
get the correct parameter name via ``auxiliary_max_tokens_param()``.
|
||||
"""
|
||||
from agent.auxiliary_client import _build_call_kwargs
|
||||
|
||||
|
|
@ -686,7 +689,7 @@ class TestBuildCallKwargsMaxTokens:
|
|||
base_url=base_url,
|
||||
task="moa_reference",
|
||||
)
|
||||
assert kwargs["max_tokens"] == 800
|
||||
assert kwargs[expected_key] == 800
|
||||
|
||||
def test_moa_task_sends_max_tokens_on_anthropic_wire(self):
|
||||
"""MoA tasks on Anthropic-compat endpoints keep max_tokens (unchanged behavior)."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue