fix(model-contract): coerce integer float token limits in projection - #5606
Open
vaibhavsrv wants to merge 1 commit into
Open
vaibhavsrv wants to merge 1 commit into
vaibhavsrv wants to merge 1 commit into
Conversation
This was referenced Sep 17, 2026
This was referenced Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters
In
ods/bin/pixel_model_contract.py, the model limits resolverprojection()evaluates override parameters across SDK defaults, selected model params, and agent configs. When parsingmaxTokens,max_completion_tokens, ormax_tokens, line 78 explicitly admits finite positive floating-point values:if (type(value) is int or type(value) is float and math.isfinite(value)) and value >= 0: output, resolved = value, True. However, line 84 bindsmaxOutputTokens: output, and downstream boundary assertions (lines 87 and 89) strictly mandatetype(limits[key]) is not intto raiseModelError("invalid-model-limits"). Consequently, configurations containing integer-valued floats (e.g.4096.0, often produced by JSON/YAML parsers, SDK float serialization, or calculated budgets) are admitted at resolution time but immediately fail contract projection withModelError('invalid-model-limits').This fix surgically checks
value.is_integer()and castsoutput = int(value)when resolving token limit overrides inprojection(). Fractional floats (such as4096.5) or non-finite values are rejected, preserving discrete token count constraints while ensuring integer-valued floats cleanly project to valid integers. Existing contract validation, compaction defaults, and route binding semantics remain untouched.Validation
{"params": {"max_tokens": 4096.0}}intoprojection(config)admitted the value intooutputbut subsequently crashed at thetype(limits[key]) is intcheck withModelError('invalid-model-limits').4096.0) resolve cleanly to integer4096inlimits["maxOutputTokens"], while non-integral floats (4096.5) and non-finite floats continue to be rejected withModelError('invalid-model-limits')."[Model-contract] suites: 4 passed. New-test Ruff, ShellCheck, and diff checks pass; new regressions wired into Linux CI."Overlap check
fix(pixel-relay): return 502 bad gateway when upstream model router is unavailable): Addressed reverse proxy upstream connectivity inpixel-model-relay; does not touch model contract metadata projection inods/bin/pixel_model_contract.py.fix(pixel-edge): accumulate content before finish reason in stream fallback guard): Focused on edge runtime streaming chunks; no overlap with model contract limits validation.fix(pixel): guard task group exception groups during stream revocation cleanup): Addressed task group cleanup; no overlap with contract resolution.Risk / AI disclosure
AI-assisted investigation, implementation and CLI regressions. This strengthens model contract token limits resolution, not runtime admission. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.
Follow-up integration evidence
Composed with #5605 at ef21605 without conflicts. Production and test diffs passed together; pixel model transition and contract checks remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.