Skip to content

Validation error for f.object(...).array() used as input field #446

@archasek

Description

@archasek

I’m seeing a validation error when using f.object(...).array() for an input field.

Minimal repro (simplified)

import { ax, f } from "@ax-llm/ax";

const sig = f()
  .input(
    "items",
    f
      .object(
        {
          id: f.number("Index"),
          name: f.string("Name"),
        },
        "Item",
      )
      .array(),
  )
  .output(
    "classifiedItems",
    f
      .object(
        {
          id: f.number("Index"),
          label: f.string("Label"),
        },
        "Classification",
      )
      .array(),
  )
  .build();

const gen = ax(sig);

await gen.forward(llm, {
  items: [
    { id: 0, name: "Foo" },
    { id: 1, name: "Bar" },
  ],
});

Actual behavior

At runtime, Ax fails during validation with an error similar to:

Validation failed: Expected 'items' to be a an array of object instead got 'array' ([{"id":0,"name":"Foo"}, ...])

If I change the input field to a looser schema:

.input("items", f.json("Item {id, name}").array())

then the same payload works fine and the model call succeeds. The issue seems specific to f.object(...).array() on inputs; using f.object(...).array() on outputs works as expected.

Is f.object(...).array() for inputs supposed to be supported, or is this a current limitation/bug in the validator?

Metadata

Metadata

Assignees

No one assigned

    Labels

    julesGoogle Jules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions