Conversation
Auxiliary context compression configured with provider=github-copilot and a
GPT-5 series model failed with HTTP 400 ("Unsupported parameter: 'max_tokens'
... Use 'max_completion_tokens'"), falling back to a static context marker and
dropping middle turns without a semantic summary.
_build_call_kwargs only emitted max_completion_tokens for provider=="custom"
on api.openai.com. github-copilot normalises to provider="copilot", so the
compression call_llm path fell through to max_tokens. Key the parameter choice
on the resolved request hostname (api.openai.com + api.githubcopilot.com),
matching auxiliary_max_tokens_param which already lists both hosts.
Closes NousResearch#34530
…isation The auxiliary_client fix in this PR routes max_tokens to max_completion_tokens for api.openai.com (and api.githubcopilot.com) — these endpoints reject the legacy parameter name on newer GPT-4o/o-series/GPT-5 models. The existing temperature-retry tests asserted retry_kwargs['max_tokens'] == 500 without considering the param-name normalisation that happens for those hosts. The retry path correctly preserves the budget — only the key name changes. Accept either max_tokens or max_completion_tokens in the assertion.
Contributor
Contributor
Author
|
Closing as superseded by #34845 ( My PR converted |
This was referenced Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
max_completion_tokens(notmax_tokens) when the resolved request endpoint is GitHub Copilot or direct OpenAI.Motivation
Closes #34530.
When
auxiliary.compressionis configured withprovider: github-copilotand a GPT-5 series model, the compression summary request failed with:Hermes then inserted a static fallback context marker and dropped middle conversation turns without a semantic summary.
Root cause:
_build_call_kwargsonly emittedmax_completion_tokensforprovider == "custom"onapi.openai.com. GitHub Copilot normalises toprovider == "copilot"(see_normalize_aux_provider/_PROVIDER_ALIASES), so thecall_llm→_build_call_kwargscompression path fell through to the genericmax_tokensbranch. Notablyauxiliary_max_tokens_param(used on the main-model path) already lists bothapi.openai.comandapi.githubcopilot.com— the two were inconsistent.The fix keys the parameter choice on the resolved request hostname rather than the provider label, covering both
api.openai.comandapi.githubcopilot.comregardless of whether the provider iscopilot,custom, oropenai. This brings_build_call_kwargsin line withauxiliary_max_tokens_param.Verification
python3 -m pytest tests/agent/test_auxiliary_client.py tests/agent/test_unsupported_parameter_retry.py— 204 passedTestBuildCallKwargsMaxTokensParamcovers: copilot provider + copilot host →max_completion_tokens; copilot host with/chat/completionspath; direct OpenAI host;provider="custom"+ OpenAI host (pre-existing behaviour preserved); OpenRouter still usesmax_tokens; unknown/empty host still usesmax_tokens(no regression for DeepSeek/etc.).