Skip to content

Design: let an invoke argument carry a JSON Schema for what is inside it #116

Done

Description

@hexuria

Rewritten on 2026-11-23 after looking at how hexuria/buwiz-forms#265 uses recipes. The gap is unchanged. The fix is no longer a nesting language of our own: an argument spec may carry a standard JSON Schema that the app supplies.

Gap

An app schema can say an invoke arg is an object or an array, but not what is inside. ArgSchema has type and required, and check_invoke_args checks the top-level type and stops.

Measured at f6cbb86, with an app schema whose x.save declares rows (array), meta (object), tags (array) and weird ("type": "strng"), written with items and properties the way an author might expect to work:

args recipe validate
{"rows": [{"id": 1}], "meta": {"owner": "me"}, "tags": ["a"]} ok
{"rows": "not-an-array"} recipe_invalid_args: arg rows must be array
{"rows": [1, "x", null, {"id": "not-an-int"}], "meta": {"owner": [1, 2]}, "tags": [1, 2, 3], "weird": 5} ok

Three things are visible in the last row:

  1. Contents are not checked.
  2. items and properties in the schema file are read and dropped, with no error or warning.
  3. A type name that is not one of the six is not checked, so a typo (strng) turns the check off. This is documented, and still easy to hit.

What changed in the plan

The first version of this issue added items and properties to ArgSchema, each another ArgSchema. Looking at a real app changed that:

  • In buwiz-forms the main nested argument is form.fill's fields: a map whose keys are the boxes of one tax form. The keys differ for every form, so no fixed nested description fits it.
  • The app already describes those shapes itself, as JSON Schema, at run time (form.schema, and the input_schema its recipe generator returns), and checks values with its own form.check invoke.

A second, smaller schema language of ours would be one more thing to keep in step with JSON Schema, and it still could not describe that argument.

Proposal

  1. An argument spec may carry a JSON Schema. An optional schema on ArgSchema, holding a standard JSON Schema for that argument's value. The app writes it, or exports it from its invoke table (Design: an app declares its invokes once, in a table the SDK serves #117). check_invoke_args validates the value against it once any placeholders are bound. type and required keep working alone.
  2. Deep checks stay in the app. Where the shape depends on run-time state, the app checks it when the invoke runs, or through a dry-run invoke of its own. Nothing in gpui-agent tries to describe that.
  3. Decide the two silent cases (points 2 and 3 above), apart from the rest: refuse an unknown key in an argument spec and an unknown type name when the schema file is loaded (recipe_invalid_schema), or keep accepting them. Refusing is a behavior change for files that load today.

ArgSchema is #[non_exhaustive] since 0.4.0, so a new field does not break Rust callers.

Open questions

  1. Which validator checks the embedded schema. jsonschema is a dev-dependency of the recipe crate today; using it at run time adds about 40 crates to the CLI.
  2. Placeholders inside nested values: an optional param with no value is already left out "at any depth in args", but coerce_invoke_args converts a bound "$id" to its declared type only at the top level.
  3. Whether an embedded schema may be a $ref to something the app serves, or must be inline.

Done when

Builds on #117. Related: #115.

Activity

  1. added
    enhancement
    on Nov 23, 2026
  2. changed the title [-]Design: let an app schema describe what is inside object and array invoke args[/-] [+]Design: let an invoke argument carry a JSON Schema for what is inside it[/+] on Nov 23, 2026
  3. hexuria commented on Nov 30, 2026

    @hexuria
    OwnerAuthor

    Probe at fbd3856 (v0.5.0): verified. ArgSchema still exposes only the top-level type/required shape; nested object/array content is unchecked, and unknown keys/type spellings are still silent design decisions.

    Plan:

    1. After Design: an app declares its invokes once, in a table the SDK serves #117 establishes the invoke table, add an optional standard JSON Schema payload on argument specs.
    2. Validate embedded schemas after recipe params are bound; keep deep/runtime-dependent validation in the app.
    3. Decide and document the two silent cases. My implementation preference is fail closed for unknown argument-spec keys and unknown type names, but because that is a compatibility decision I will call it out explicitly in the PR.
    4. Measure dependency cost before choosing the validator; jsonschema is currently dev-only and pulling it into the CLI runtime is not free.

    This remains blocked behind #117 and is not part of the first small-fix batch.

  4. hexuria commented on Nov 30, 2026

    @hexuria
    OwnerAuthor

    Implemented and merged in PR #141 (336617c). Embedded invoke argument JSON Schemas now round-trip over the live invoke table and schema files, compile offline with bounded regex validation, deep-validate bound recipe values, and distinguish runtime step-node references from literal node-shaped user data.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions