Skip to content
Source
Sign inSign up
TanStack/ai

`convertSchemaToJsonSchema` works incorrectly for arktype #276

Send to my agent
ClosedSekky61(GitHub profile, opens in a new tab) opened this issue 0 comments

TanStack AI version

v0.4.2

Framework/Library version

React v19.2.0, Arktype v2.1.28

Describe the bug and the steps to reproduce it

convertSchemaToJsonSchema returns a function instead of object. I ran into this while trying to use the openrouter adapter. The openrouter sdk does it's own validation and did not accept the tool schema.

import { type } from "arktype";
import { convertSchemaToJsonSchema } from "@tanstack/ai";

describe("convertSchemaToJsonSchema", () => {
  it("returns an object", () => {
    const schema = type({
      foo: "boolean",
    });
    const jsonschema = convertSchemaToJsonSchema(schema);
    expect(typeof jsonschema).toEqual("object");
    // Expected: "object"
    // Received: "function"
  });
});

In the meantime, this works for me:

import type { JSONSchema } from "@tanstack/ai";
import { type } from "arktype";

const inputSchema = type({
  foo: 'boolean'
}).toJsonSchema() as JSONSchema;

// toolDefinition...

Related: https://arktype.io/docs/type-api#tojsonschema

see the test included in issue

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

None

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
  1. AlemTuzlak closed this

Sign in to join this conversation.