What happened?
I'm using OpenAI models via a proxy and the context reported by this proxy is wrong. I've disabled auto compact for Pi so my context used is 400% of what's available haha. Becuase of this, the upstream provider is rejecting my requests with 400 Bad Request:
Invalid 'max_output_tokens': integer below minimum value. Expected a value >= 16, but got 1 instead.
The Responses API path in Pi's code already floors to 16 (OPENAI_RESPONSES_MIN_OUTPUT_TOKENS = 16), but openai-completions.ts passes the raw clamped (1 here) value through with no floor.
clampMaxTokensToContext in simple-options.ts uses MIN_MAX_TOKENS = 1 as its floor, and openai-completions.ts (lines 570-574) sends that straight to the provider.
Steps to reproduce
- Have a proxy configure context lower than actually served context. And have your session exceed 100% of the context window.
- Send another message, context estimation + 4096 safety margin pushes available to ≤ 1.
- Request fails with 400 from the provider.
Expected behavior
max_completion_tokens should never be sent below the provider's minimum (16). The completions path should floor it the same way the Responses API does.
Version: 80.6
What happened?
I'm using OpenAI models via a proxy and the context reported by this proxy is wrong. I've disabled auto compact for Pi so my context used is 400% of what's available haha. Becuase of this, the upstream provider is rejecting my requests with 400 Bad Request:
The Responses API path in Pi's code already floors to 16 (OPENAI_RESPONSES_MIN_OUTPUT_TOKENS = 16), but openai-completions.ts passes the raw clamped (1 here) value through with no floor.
clampMaxTokensToContext in simple-options.ts uses MIN_MAX_TOKENS = 1 as its floor, and openai-completions.ts (lines 570-574) sends that straight to the provider.
Steps to reproduce
Expected behavior
max_completion_tokens should never be sent below the provider's minimum (16). The completions path should floor it the same way the Responses API does.
Version: 80.6