Skip to content

fix: floor responses max_output_tokens to 16 for tiny budgets - #63

Merged
jasonxu114514 merged 1 commit into
jasonxu114514:mainfrom
ahoo:fix/responses-max-output-floor
Oct 15, 2026
Merged

jasonxu114514 merged 1 commit into
jasonxu114514:mainfrom
ahoo:fix/responses-max-output-floor

Conversation

@ahoo

@ahoo ahoo commented Oct 10, 2026

Copy link
Copy Markdown

问题

claude code 这类下游会发 max_tokens < 16 的小请求(后台 title 等内部任务),经 chat→responses 转换后原样透传为 max_output_tokens,Zen responses 端点硬校验 >= 16,直接 400:

max_output_tokens The number must be >= 16.

更糟的是网关把这类确定性 400 当可重试错误,在全部匿名出口上扫一遍(16 attempts,白白十几秒),最后还是把 400 抛给下游。

复现

max_tokens=8 调任意 responses 原生免费模型(如 muse-spark-1.3-contributor-free),稳定复现。

修复

encodeResponsesRequest 里对 max_output_tokens 做下限:0 < n < 16 抬到 16,其余(nil、大预算)原样透传,正常请求零行为变化。

验证

  • max_tokens=8/10:之前 400×16 跳,现在 200 1 跳
  • 正常预算请求:行为不变
  • gofmt + docker 构建通过

@jasonxu114514
jasonxu114514 merged commit 05f0faf into jasonxu114514:main Oct 15, 2026
jasonxu114514 added a commit that referenced this pull request Oct 15, 2026
Zen's Responses endpoint rejects max_output_tokens below 16, and clients
such as Claude Code send tiny budgets for background tasks. The 400 was
retried across every anonymous exit before reaching the client. Raise
budgets in (0, 16) to 16 on both the bridged and the same-protocol
Responses paths; nil and larger budgets pass through unchanged.

Co-authored-by: ahoo <[email protected]>
SK-DEV-AI added a commit to SK-DEV-AI/opencode2api that referenced this pull request Oct 15, 2026
…ver-key usage)

Takes upstream f8e996d/be91f86/0204ca1 (client fingerprint + inference
endpoint + genuine tools), jasonxu114514#59 anon cooldown lockup, jasonxu114514#63 token floor,
jasonxu114514#64 whole-attempt deadline, jasonxu114514#62 tool images, jasonxu114514#58 server-key usage
split, jasonxu114514#65/jasonxu114514#66 models surface, plus our merged jasonxu114514#76/jasonxu114514#77/jasonxu114514#78.

Kept local (fork-owned, still no upstream equivalent): zero-delivery
replay + length rescue + SSE heartbeat + stop/tail census (stream
lanes), offline no_upstream_contact probe guard, single-marshal Zen
shaping with paid-model gate, tcp4 dial + TLS resumption, RandomID
math/rand fallback, cancel-detached refresh fix (PR jasonxu114514#80 superseded by
maintainer feedback; kept locally pending lifetime-context rework).
Telemetry takes upstream's session-burn + server-key split with their
LRU session cap (better than our smallest-first); CloneMap takes
upstream's merged comment. Metrics ring test retargeted at upstream's
concrete ring types. doUpstream keeps upstream's 3-value signature;
replay uses a new doUpstreamCounted wrapper for continuous legs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants