Skip to content

fix(auxiliary): stop capping output with max_tokens by default (#34530) - #34845

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-73915d12
May 30, 2026
Merged

teknium1 merged 2 commits into
mainfrom
hermes/hermes-73915d12

Conversation

@teknium1

@teknium1 teknium1 commented May 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Auxiliary LLM calls no longer cap output with max_tokens by default — they let the model max out its own output, which is the behavior we want for compression summaries, titles, vision, etc.

Closes #34530. Root cause: _build_call_kwargs sent max_tokens on the OpenAI-compatible path, but GitHub Copilot / GPT-5 models reject it (require max_completion_tokens). Compression 400'd and fell back to a static context marker. Rather than translate the param name per-provider, we just stop sending it.

Changes

  • agent/auxiliary_client.py: _build_call_kwargs omits max_tokens for all OpenAI-compatible chat-completions providers (Copilot, OpenAI, OpenRouter, Nous, local, ZAI). The Anthropic Messages wire (MiniMax + any /anthropic endpoint) keeps it — max_tokens is a mandatory field there. This collapses the old host-sniffing + ZAI-vision-skip branches into one Anthropic-compat check.
  • tests/agent/test_auxiliary_client.py: new TestBuildCallKwargsMaxTokens — 9 cases asserting omit-by-default for OpenAI-family, keep-it for the Anthropic wire.

Validation

endpoint before after
Copilot gpt-5.x max_tokens → 400 omitted → model max
OpenAI gpt-5 max_completion_tokens omitted → model max
OpenRouter / Nous / local max_tokens omitted → model max
ZAI vision skipped (special-cased) omitted (no special case)
MiniMax / /anthropic max_tokens max_tokens (unchanged — mandatory)

E2E with real imports across 8 endpoints + test_auxiliary_client.py and test_context_compressor.py: 279/279 pass.

Infographic

auxiliary-max-tokens-omit

ghost commented May 29, 2026

Copy link
Copy Markdown

🔎 Lint report: hermes/hermes-73915d12 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9455 on HEAD, 9455 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4909 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

teknium1 added 2 commits May 29, 2026 13:38
Auxiliary LLM calls (compression, titles, vision, etc.) no longer send
max_tokens on the OpenAI-compatible chat-completions path. Most providers
treat an omitted max_tokens as "use the model max", which is what we want;
an explicit cap only risks truncation or a wire-format 400.

This was surfaced by GitHub Copilot / GPT-5 (#34530): those models reject
max_tokens and require max_completion_tokens, so compression 400'd and fell
back to a static context marker. Omitting the param sidesteps that quirk
(and ZAI vision's error 1210) entirely.

The Anthropic Messages wire (MiniMax + /anthropic endpoints) keeps
max_tokens because it is a mandatory field there.
…tokens

The temperature-retry tests asserted retry_kwargs["max_tokens"] == 500 on an
api.openai.com endpoint. Now that auxiliary calls omit max_tokens on
OpenAI-compatible endpoints (#34530), that key is absent. Assert it's absent
in both first and retry kwargs and use model as the survives-the-retry witness.
@ghost
ghost force-pushed the hermes/hermes-73915d12 branch from fd90d42 to 6ae3a7a Compare May 29, 2026 20:38
@ghost ghost added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels May 29, 2026
@ghost
ghost merged commit 2062a84 into main May 30, 2026
@ghost
ghost deleted the hermes/hermes-73915d12 branch May 30, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auxiliary context compression sends max_tokens to GitHub Copilot GPT-5 models

2 participants