Skip to content

fix(model-contract): coerce integer float token limits in projection - #5606

Open
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/model-contract-float-output-limits
Open

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/model-contract-float-output-limits

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In ods/bin/pixel_model_contract.py, the model limits resolver projection() evaluates override parameters across SDK defaults, selected model params, and agent configs. When parsing maxTokens, max_completion_tokens, or max_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 binds maxOutputTokens: output, and downstream boundary assertions (lines 87 and 89) strictly mandate type(limits[key]) is not int to raise ModelError("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 with ModelError('invalid-model-limits').

This fix surgically checks value.is_integer() and casts output = int(value) when resolving token limit overrides in projection(). Fractional floats (such as 4096.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

  • Baseline reproduction: Passing {"params": {"max_tokens": 4096.0}} into projection(config) admitted the value into output but subsequently crashed at the type(limits[key]) is int check with ModelError('invalid-model-limits').
  • Post-fix behavior: Integer-valued floats (4096.0) resolve cleanly to integer 4096 in limits["maxOutputTokens"], while non-integral floats (4096.5) and non-finite floats continue to be rejected with ModelError('invalid-model-limits').
  • Telemetry statement: "[Model-contract] suites: 4 passed. New-test Ruff, ShellCheck, and diff checks pass; new regressions wired into Linux CI."

Overlap check

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.

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.

1 participant