Repository navigation
feat(openai-chat): minMaxOutputTokens provider floor for guaranteed output budgets - #6696
ismell0992-afk wants to merge 9 commits into
Conversation
…utput budgets Add an optional minMaxOutputTokens floor on OcxProviderConfig: the effective max_tokens sent upstream is max(declared, floor), where declared is the caller's max_output_tokens, then modelMaxOutputTokens, then defaultMaxOutputTokens. Motivating case is local/OpenAI-compatible servers (llama.cpp, Ollama): a client sending a tiny budget would otherwise leave a reasoning model zero tokens for content. Floor only; a larger declared value always wins, and the floor is off when unset or <= 0. - types/provider.ts: new optional field with doc comment - model-rename-fields.ts: classified "none" (satisfies map is enforced) - auth-cors.ts: field policy "editor", matching its budget siblings - config-schema.ts: positiveIntegerConfigError parity with defaultMaxOutputTokens, so bad values are rejected at load - summary-budget.ts: resolveMaxTokens applies the floor - tests: unit + wire-level floor cases; config-schema accept/reject cases - docs: providers reference row (English; translations follow)
|
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This pull request was already a draft. Its draft status will be preserved after every issue above is resolved. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to The OpenAI Chat token floor is ready to merge after normal checks. Pre-merge checks |
|
…nothing is declared
|
Self-review pass (senior-reviewer subagent) completed before marking ready. Outcome: Applied: docs row now states explicitly that when nothing is declared, the floor itself is sent ( Considered, declined with reasoning: tightening the runtime floor guard from Verification evidence (from the TDD run; reviewer was read-only so these are the executor's records): new test file fails 5/9 at the base commit (runtime red), 9/9 at head; |
Provider-management PATCH rejects patches naming only unrecognized fields, so the field cannot be persisted through that path today; the guard belongs in providerManagementConfigError regardless, so a future PATCH handler for it cannot persist a value the schema load would reject and sink the whole provider config to fallback. Also reconcile the type doc with the unset behavior (the floor itself is sent when nothing is declared) and name the openai-chat-only scope.
Ingwannu
left a comment
There was a problem hiding this comment.
Scoped correctness review at 95d9a34; not a security sign-off or CI authorization. The configured floor is not enforced for native Chat ingress (inline P2). Please also document the owning configuration/Chat compatibility contract in structure/ when settling that scope. The independent auth-cors sponsorship/review gate remains outstanding; the checked self-review box does not satisfy it. No author-branch edits or live provider calls were made.
…kens-floor # Conflicts: # scripts/test-layout/layout.json # tests/fixtures/test-layout-expected.json
Reuse Chat budget resolution for native streaming and buffered requests. Prefer max_completion_tokens and omit conflicting legacy caps when the floor is enabled; preserve unset behavior and caller state. Co-authored-by: ismell0992-afk <[email protected]>
Some Azure Responses deployments reject Claude Code's tiny model-switch validation budget. Add opt-in provider setting minMaxOutputTokens for the azure / azure-openai adapter: explicit positive integer max_output_tokens below the floor are raised to it; unset providers, omitted or invalid budgets, and larger budgets are unchanged. Spend admission reserves the same effective cap at final route normalization and for each Combo target, and Combo restores the caller's ceiling for targets without a floor. Based on #7012 by @tsruu. Supersedes #6696 by @ismell0992-afk. Co-authored-by: tsruu <[email protected]> Co-authored-by: ismell0992-afk <[email protected]>
|
Thank you, @ismell0992-afk, and to everyone who iterated on this. The #7012 and this PR solved the same problem with the same field, so we had to pick one design. #7028 takes the narrower one: opt-in, applied to the If you still need the floor on an |
Summary
minMaxOutputTokensfor OpenAI Chat providers. Native Chat and translated Responses raise the effective caller/model/provider budget to the configured floor; larger budgets remain intact. With the option unset, existing fields and omissions remain unchanged. Nativemax_completion_tokenstakes precedence over the legacy alias.Verification
249397048fbe87255715af90255bdb06d8bd017c; contained dev:7af092ca4f78828238b425bf351d5989e237f89f; original contributor commit95d9a3498fb7c5d3ad2a29071cec1c348dc31076remains an ancestor.bun test --isolate tests/responses/chat-output-floor-copilot-auto.test.ts tests/responses/chat-native-spend.test.ts tests/responses/chat-native-combo.test.ts tests/responses/responses-spend-anchor.test.ts tests/lib/execution-budget-permits.test.ts tests/lib/spend-seed-overflow.test.ts: 198 pass / 0 fail. The 12 Auto cases verify direct/combo streaming/buffered refusal with zero inference sends, unset-floor success, and sufficient-capacity reservations.bun run typecheck,bun run structure:check, andbun run privacy:scan: exit 0.bun run --cwd docs-site build: exit 0, 569 pages and 79,332 internal links; no dependency manifest or lockfile changes.Checklist
Review readiness checklist