Skip to content

[P1] Reject coerced types at the Intent IR boundary before agent plans are admitted #56

Closed

Description

@AetherAI3

Problem and evidence

At main d740bb530262c1c76a2b18c8a8aa47476f8b6b96, the published Intent JSON schema and Python admission behavior disagree. Starting with compile_intent("spy earnings").to_dict():

  • Set confidence = True: validate_document accepts it as 1.0.
  • Set confidence = "0.9": it accepts a string as 0.9.
  • Set entities[0].kind = 42: it accepts the number as the string "42".

IntentIR.from_dict and IntentEntity.from_dict apply float(...) and str(...) before type validation. schema.py delegates validation to this path. The published schema requires a JSON number for confidence and a string for entity kind.

This becomes more consequential when local models or agent tools generate plan JSON: invalid proposals should receive a repairable error, not acquire a different meaning during admission.

Agent work packet

Remove implicit coercion of invalid input types. Accept genuine JSON integer/float confidence values, excluding booleans; check finiteness and range before normalization. Require an actual string for entity kind. Keep the existing IR version and canonical bytes for valid compiler-produced plans.

Acceptance

  • Bool, numeric-string, null, non-finite and out-of-range confidence are rejected through IntentIR.from_dict, validate_document and canonical serialization with a controlled IntentValidationError.
  • Non-string entity kinds are rejected.
  • Numeric confidence 0, 0.5 and 1 remain valid; compiled golden plans retain canonical bytes.
  • Include positive controls and direct-constructor/API coverage where applicable.
  • Run focused Intent tests and the reference suite, separating unrelated baseline failures.

Delivery and limits

One focused main-based PR. No changes to model routing, inference providers, network effects or QPU authority. This issue does not attempt to solve all future proposal-schema validation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions