CodeWhale icon indicating copy to clipboard operation
CodeWhale copied to clipboard

[BUG] Custom openai-compatible provider: output budget clamped to the hosted-catalog ceiling (32K for qwen3.8-27b) even though the server accepts 262K — reasoning models return empty terminal stops

Open Gabriel-Degret opened this issue 1 month ago • 4 comments

Before you start

  • [ ] I searched existing issues and this is not a duplicate. 我已搜索过现有 issue。

What happened? 发生了什么?

What happened?

When a provider is configured as kind = "openai-compatible" in front of an operator-owned vLLM server (e.g. a lab proxy), the output budget sent to the server is clamped to the hosted catalog row's limit.output — 32768 tokens for qwen3.8-27b — even though the server itself accepts far more.

Verified against the real server (vLLM 0.32.0): max_tokens = 131072, 262144 and 262000 are all accepted (HTTP 200, finish_reason=stop). The runtime still emits max_tokens=32768.

With a reasoning model at reasoning_effort: high or xhigh, the model spends the entire 32K allowance on hidden reasoning and never produces visible text. The server returns a terminal stop with no answer, and the turn fails after two retries:

Model returned terminal stop reason stop with no answer or tool call (after 2 retries)

This makes long sub-agent tasks (reviews, planning, verification) fail reliably end-to-end.

Root cause (traced in the code)

  1. The embedded model catalog (crates/config/assets/models_dev.bundled.json) declares for qwen/qwen3.8-27b:

    "limit": { "context": 262144, "output": 32768 }
    
  2. route_budget.rs::effective_max_output_tokens_for_route intersects the requested cap with the compatibility cap. For a Custom provider, the catalog-derived max_output (32768) is applied, so every request goes out with max_tokens=32768.

  3. The same failure shape — reasoning consuming the entire output allowance, zero visible text — is already documented in route_budget.rs for another route class (#6285).

Custom providers are operator-owned endpoints, like the Ollama / SGLang / VLLM routes that already have an operator-owned allowlist in route_declares_unknown_output_ceiling — but Custom itself is not in that allowlist, so a catalogued model name is still clamped by the hosted row.

Expected behavior

For custom openai-compatible endpoints in front of operator-owned engines, use the operator's real serving ceiling instead of the hosted-catalog limit.output:

  • Add ProviderKind::Custom to the operator-owned allowlist in route_declares_unknown_output_ceiling (alongside Ollama / SGLang / VLLM).
  • Honor the catalog's generation_default when present, otherwise the generic automatic cap.
  • Keep the window-relative ContextBudget clamp as the hard cap (never raise any cap, only stop under-clamping).
  • Unify the "custom" label with the existing Unverified/RouteDeclaredUnknown provenance so receipts stay truthful.
  • Run cargo test route_budget (and add a regression test for the Custom route with a catalogued model name).

Steps to reproduce 复现步骤

  1. Configure a provider:

    [providers.myqwen]
    kind = "openai-compatible"
    base_url = "https://your-vllm-host/api"
    model = "qwen3.8-27b"
    
  2. Run any task at reasoning_effort = "high" or "xhigh" (e.g. a review or planning sub-agent).

  3. Observe the repeated empty terminal stop and the failed turn.

  4. Compare the emitted request (max_tokens=32768) with the server's accepted values (262144 works).

Environment

  • Codewhale version: 0.10.2 (main @ 44007bf)
  • Where: TUI + sub-agents
  • OS: FreeBSD
  • Channel: built from source
  • Provider / model: custom openai-compatible → qwen3.8-27b (vLLM 0.32.0)

Codewhale version 版本

Codewhale 0.10.2

Where did it happen? 在哪里出现?

TUI (terminal interface)

Operating system 操作系统

Other

How did you get Codewhale? 获取方式

Cargo (crates.io)

Provider and model 提供商和模型

No response

Terminal and shell 终端

No response

codewhale doctor (optional)

Logs, screenshots, anything else (optional)

Extra notes

  • Same failure class as #6285; related budget work: #5518, #5820, #6540, #5461.
  • Workaround today: set CODEWHALE_MAX_OUTPUT_TOKENS=262144 (env) or lower reasoning_effort.
  • Optional separate change: correct the catalog limit.output for qwen/qwen3.8-27b (32768 → 262144) with fresh server evidence.
  • I searched existing issues: no open issue or PR covers this case (searched: qwen, qwen3.8, 27b, empty stop, output cap, vllm ceiling, custom endpoint).

Engine packet, October 31. Trace the custom endpoint output cap from route lookup to the wire. Scope is crates/engine/src/route_budget.rs and the existing config/model catalog accessors only as needed. Verify with exact wire requests on a loopback custom route and the existing route-budget checks.

Candidate landed on Engine main 1d750e5098. With a 262144-token configured window, six ordinary CLI turns across qwen3.8-27b, qwen/qwen3.8-27b, and alibaba/qwen3.8-27b now emit 65536 automatic and 131072 explicitly requested on a custom OpenAI-compatible transport. The third spelling reproduced 32768 before the fix, while the first two already honored the larger values on this base and window. The initial scoped suite had 43/44 passes. The existing assertion for the modified provenance label was updated and its rerun passed. Real FreeBSD/vLLM reasoning output is an outstanding reporter surface.

Gabriel-Degret avatar Nov 01 '26 00:11 Gabriel-Degret

These are indeed really headache-inducing problems. I submitted a PR a few days ago, but it didn’t fully cover these issues.

It’s not just these small models—for some third-party relay/proxy services, if the model name doesn’t match the built-in list in CodeWhale, it will automatically fall back to a 128K context—that’s a disaster. Later on, I’ll submit another PR to continue pushing forward with the fix for this issue.

SparkofSpike avatar Nov 01 '26 01:11 SparkofSpike

Please see the merged PR #7183. I attempted to fix this issue. You can try compiling the current main to see if your problem has been resolved. It seems to have been verified on my end. If the problem persists, feel free to follow up with feedback in this issue anytime.

SparkofSpike avatar Nov 03 '26 04:11 SparkofSpike

Thank you @Gabriel-Degret for the detailed trace of the max_tokens clamp, and @SparkofSpike for following up and for PR #7183, which fixed a related catalog-lookup case. Commit 1d750e5098b on main stops named custom openai-compatible endpoints from inheriting the hosted catalog row's output ceiling. The automatic budget now follows the model's generation default (or half the declared context window), and an explicit max-output setting can go higher, still within the context window. This is on main but not in the published 0.10.2 package, so the issue stays open until 0.10.3 ships. After that (or from a main build), please retry your qwen3.8-27b setup at high/xhigh reasoning effort and tell us whether the empty terminal stops are gone.

Written by Claude Opus 5.5 for the Codewhale maintainers.

Hmbown avatar Nov 10 '26 21:11 Hmbown

Thank you @Gabriel-Degret for tracing the 32K max_tokens clamp to the hosted catalog row and checking what your vLLM server actually accepts. The fix shipped in v0.10.3 (1d750e5098): a named custom openai-compatible endpoint no longer inherits the hosted output ceiling. Upgrade with npm install -g [email protected]. We could not test against your server, so please reopen if qwen3.8-27b at high or xhigh reasoning effort still returns empty terminal stops.

Hmbown avatar Nov 22 '26 12:11 Hmbown