Skip to content

Document strict tool selection and numeric range precision - #461

Open
jcartu wants to merge 1 commit into
NVIDIA:mainfrom
jcartu:pr/strict-numeric-bounds
Open

jcartu wants to merge 1 commit into
NVIDIA:mainfrom
jcartu:pr/strict-numeric-bounds

Conversation

@jcartu

@jcartu jcartu commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Why

Named and required tool_choice modes do not by themselves constrain token sampling, while compile_strict_validators compiles every declared strict: true function schema at request admission regardless of tool_choice (including unselected tools and tool_choice: "none"). Separately, strict numeric enum and const literals enforce an exact magnitude cap strictly below 2^53, whereas llguidance =1.9.1 interprets minimum, maximum, exclusiveMinimum, and exclusiveMaximum at IEEE 754 binary64 precision and rejects bounds outside its supported numeric range. Rejecting every range bound at or above 2^53 at admission would reject inclusive integer maxima such as 9223372036854775807 (2^63 - 1) that the grammar enforces exactly; documenting the admission scope, binary64 rounding cases, and refused range bounds preserves valid large maxima without overstating exactness.

What changed

  • docs/api.md: states that named and required selection add no decoding constraint by themselves; defines an active strict: true function tool once; states that every declared strict: true schema is validated at admission even when unselected or under tool_choice: "none"; separates the < 2^53 enum/const literal limit from IEEE 754 binary64 range-bound interpretation; documents both rounded bounds (minimum: 9007199254740993, exclusiveMinimum: 9007199254740992) and admission-refused bounds (minimum: -9223372036854775808 on integer, minimum: 1152921504606846976 on number returning HTTP 400); and advises exact arithmetic validation before executing a tool when large admitted bounds can round.
  • docs/TODO.txt: adds an entry tracking exact decimal enforcement or explicit rejection of strict: true numeric range bounds above 2^53 and its closure criterion.
  • helios/src/grammar/strict.rs: extends strict_bounds_do_not_round_integers_or_fractional_multiples to pin exact inclusive integer maxima (10^18, i64::MAX), the documented minimum and exclusiveMinimum binary64 rounding cases, and schema-admission rejection of minimum: -2^63 on integer and minimum: 2^60 on number.

Claimed result

Runtime admission and decoding behavior are unchanged relative to main. The API reference and docs/TODO.txt accurately describe strict-tool admission scope, active-grammar attachment, and IEEE 754 binary64 numeric range behavior, and unit tests pin the documented llguidance =1.9.1 outcomes so any upstream change surfaces immediately.

Evidence

  • cargo test --locked --manifest-path helios/Cargo.toml --features runtime-core,server --lib grammar::strict on Linux x86_64 CPU (rustc 1.100.0): 27 passed, 1 ignored (including strict_bounds_do_not_round_integers_or_fractional_multiples).
  • No production runtime code changed; GPU serving was not run for this documentation and unit-test change.

Discord: jcartu

@yatesdr yatesdr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Checked a640a30. The docs/api.md changes settle the two sentences our #418 review flagged: named and required selection now say a strict function still attaches its grammar.

The admission rule refuses more than the gap it closes. On main 6d6fe0c we ran a scratch test through validate_strict_tool_schema and TextGrammar::validate (aarch64 Linux, CPU only), on integer properties:

Bound Value tried Result on main
exclusiveMinimum: 9007199254740992 9007199254740992 accepted (schema forbids it)
minimum: 9007199254740993 9007199254740992 accepted (schema forbids it)
maximum: 9007199254740992 9007199254740992 / 9007199254740993 accepted / rejected (exact)
maximum: 1000000000000000000 10^18 / 10^18 + 1 accepted / rejected (exact)
maximum: 9223372036854775807 2^63 - 1 / 2^63 accepted / rejected (exact)

minimum: -9223372036854775808 on integer, and minimum: 2^60 on number, are already refused by llguidance with a range error.

  1. Exact bounds become HTTP 400s. Rejecting every magnitude at or above 2^53 also refuses the exact rows above, including the int64 limits that generated schemas emit. The PR changes main's own test from maximum: 9007199254740992 to 9007199254740991 so that it passes. Please refuse only the bounds llguidance rounds: an exclusive integer bound at or above 2^53, and a bound whose value does not survive conversion to f64 and back. Or leave admission as it is and document the limit, which docs/api.md now states.
  2. Compatibility. Whatever remains, please say in the description which requests accepted today now return HTTP 400.

Nit: the commit message's section on #418's timing provenance describes #418's evidence, not this change, and cites a commit that is not in this repository. It belongs on #418's thread, if anywhere.

@jcartu jcartu changed the title Bound strict function-tool numeric range keywords below 2^53 Document strict tool selection and numeric range precision Nov 23, 2026
@jcartu

jcartu commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@yatesdr I took the documentation alternative from your review. At e831b49 the net runtime diff against the PR base is empty: no new HTTP 400s. The original inclusive 2^53 test is unchanged, and the new regression accepts 10^18 and i64::MAX at the endpoint and rejects each successor. The strict grammar suite passed on x86_64 (28 passed, 1 ignored). The API docs identify the two rounding cases rather than claiming they are fixed; the PR description no longer cites unrelated timing results. Ready for another look.

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 461
Case File Intake Report

To opt out, include #autobot:ignore in the PR or any comment.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Full Review

Changes Requested

Blockers:

  • None.

Should fix:

  • Admission scope is unstated. The new sentences (docs/api.md:522-525, :544-546) read as if only the selected strict tool matters, but compile_strict_validators filters every strict tool with no tool_choice term (helios/src/server/request.rs:94, called unconditionally at :125), so an inadmissible strict schema is an HTTP 400 even under tool_choice: "none". → Add one clause: every declared strict: true schema must be admissible even when its tool is not selected.
  • The documented rounding deviation has no docs/TODO.txt entry. docs/api.md:605-612 records a live gap; AGENTS.md:47-55 requires unresolved defects there, not in design documents, and no entry exists. → Add one naming the missing condition and its removal criterion.
  • The rounding examples are pinned by no test. The added test (helios/src/grammar/strict.rs:3888-3898) covers only exact inclusive maximum; the minimum/exclusiveMinimum outcomes at api.md:607-609 are asserted nowhere against llguidance =1.9.1 (helios/Cargo.toml:62). → Extend the test so a dependency bump that fixes rounding fails visibly.
  • The paragraph omits bounds that are refused, not rounded. Your own table records minimum: -2^63 on integer and minimum: 2^60 on number already returning a range error (HTTP 400), where "validate in the tool" cannot apply. → Add one sentence and assert those outcomes too.

Nits:

9 nits

  • Fold the new test into strict_bounds_do_not_round_integers_or_fractional_multiples (strict.rs:3005-3025) or move it next to :3025; only i64::MAX is genuinely new.
  • Restore "IEEE 754" at api.md:600-603; the word now appears nowhere under docs/.
  • Rewrap api.md:607 (86 columns vs ~78-80) and drop the unsupported bound + 1 mechanism clause at :608-609.
  • Define "active" once (api.md:545, 614, 639, 644) and prefer "adds no decoding constraint" at :544 over "leaves sampling unconstrained".
  • Add a claimed-result sentence to the description and squash commit e831b496, whose subject describes the branch against its own parent, not main.

To opt out of future reviews, put #autobot:ignore in your response.

Named and required `tool_choice` modes do not by themselves constrain token
sampling, while `compile_strict_validators` compiles every declared
`strict: true` tool schema at request admission regardless of `tool_choice`
(including unselected tools and `tool_choice: "none"`). Separately, strict
numeric `enum` and `const` literals enforce an exact magnitude cap below `2^53`,
whereas `llguidance =1.9.1` interprets `minimum`, `maximum`, `exclusiveMinimum`,
and `exclusiveMaximum` at IEEE 754 binary64 precision and rejects bounds outside
its numeric range. Rejecting all range bounds at or above `2^53` would reject
inclusive integer maxima such as `2^63 - 1` (`i64::MAX`) that the grammar
enforces exactly; documenting the admission scope, binary64 rounding cases, and
refused range bounds preserves valid large maxima without misstating exactness.

Changes against `main`:
- `docs/api.md`: state that named and required selection add no decoding
  constraint by themselves, define an active `strict: true` function tool once,
  state that every declared `strict: true` schema must be admissible even when
  unselected or under `tool_choice: "none"`, separate the `< 2^53` `enum`/`const`
  restriction from IEEE 754 binary64 range-bound behavior, document both rounded
  bounds (`minimum: 9007199254740993`, `exclusiveMinimum: 9007199254740992`) and
  admission-refused bounds (`minimum: -9223372036854775808` on `integer`,
  `minimum: 1152921504606846976` on `number`), and advise exact arithmetic
  validation before tool execution when large bounds can round.
- `docs/TODO.txt`: record the unresolved `llguidance` IEEE 754 binary64
  range-bound rounding and range-limit gap and its closure criterion.
- `helios/src/grammar/strict.rs`: extend
  `strict_bounds_do_not_round_integers_or_fractional_multiples` to pin exact
  inclusive integer maxima (`10^18`, `i64::MAX`), the documented `minimum` and
  `exclusiveMinimum` rounding cases, and admission rejection of `minimum: -2^63`
  on `integer` and `minimum: 2^60` on `number`.

Claimed result: runtime admission and decoding behavior are unchanged; the API
reference and `docs/TODO.txt` match Helios admission and `llguidance =1.9.1`
range behavior, and unit tests fail visibly if a dependency update alters the
documented outcomes.

Evidence: `cargo test --locked --manifest-path helios/Cargo.toml --features
runtime-core,server --lib grammar::strict` passed on Linux x86_64 CPU (27 passed, 1 ignored). No
production runtime code changed; GPU serving was not run.

Design-Signed-Off-By: Gemini 4 Carbon (agent for Josh Cartu); design-review=c3a9
Signed-off-by: Joshua Cartu <[email protected]>
@jcartu
jcartu force-pushed the pr/strict-numeric-bounds branch from e831b49 to 31c9020 Compare November 28, 2026 23:30
@jcartu

jcartu commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

@flare-autobot Addressed all review items on rebased main:

  • Admission scope & active definition (docs/api.md): Stated that every declared strict: true schema must be admissible even when unselected or under tool_choice: "none", defined an active strict: true function tool once, and switched required mode to "adds no decoding constraint".
  • Tracked gap (docs/TODO.txt): Added an entry for llguidance's IEEE 754 binary64 range-bound rounding and range limits with its closure criterion.
  • Pinned rounding & refused bounds (docs/api.md, helios/src/grammar/strict.rs): Folded the 10^18 and i64::MAX checks into strict_bounds_do_not_round_integers_or_fractional_multiples alongside minimum: 9007199254740993, exclusiveMinimum: 9007199254740992, and admission rejection of minimum: -2^63 (integer) and minimum: 2^60 (number) (27 passed, 1 ignored), restored "IEEE 754", removed the unsupported mechanism clause, wrapped lines, and squashed onto main.

@flare-autobot flare-autobot added area:api Serving API, protocol encoding, tool parsing, and client-visible behavior. documentation Improvements or additions to documentation triage:review Proposed change needs code review; this does not imply merge readiness. labels Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:api Serving API, protocol encoding, tool parsing, and client-visible behavior. documentation Improvements or additions to documentation triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants