Skip to content

"Export toJSONSchema doesn't exist in target module" from betaZodTool #919

@Tajmirul

Description

@Tajmirul

i'm trying to use beta.messages.toolRunner with custom tools. This is an example:

const defaultTools: Record<string, ReturnType<typeof betaZodTool>> = {
  execute_sql: betaZodTool({
    name: "execute_sql",
    description: "Execute validated SQL and return sample results (max 5 rows)",
    inputSchema: z.object({
      sql: z.string().describe("Validated SQL query to execute"),
    }),
    run: async (args) => {
      return "";
    },
  }),
  validate_sql_output_against_widget_data_schema: betaZodTool({
    name: "validate_sql_output_against_widget_data_schema",
    description: "Validate SQL against widget data schema",
    inputSchema: z.object({
      sql: z.string().describe("SQL query to validate"),
      widgetType: z
        .string()
        .describe(
          `Widget type to validate against. Must be one of: ${Object.keys(
            widgetRegistry.getTypes(),
          ).join(", ")}`,
        ),
    }),
    run: async (args) => {
      return "";
    },
  }),
};

      const runner = await this.client.beta.messages.toolRunner({
        model: this.model,
        max_tokens: this.maxOutputTokens,
        system: systemPrompt,
        messages,
        tools: Object.values(this.tools),
        output_config: {
          format: {
            type: "json_schema",
            schema: zodToJsonSchema(AIOutputFormat, {
              name: "widget_generation_response_format",
            }),
          },
        },
      });

Then i get this error:

Image

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