Skip to content

Conversation

pavelgj
Copy link
Collaborator

@pavelgj pavelgj commented Sep 14, 2025

Right now we only validate, but if the schema has defaults or transforms those don't get applied. Ex:

  const testFlow = ai.defineFlow(
    {
      name: 'testFlow',
      inputSchema: z.object({
        foo: z.string().default('default foo'),
      }),
      outputSchema: z.object({
        input: z
          .object({
            foo: z.string().optional(),
          })
          .optional(),
        bar: z.string().transform((val) => `${val}-transformed`),
      }),
      schemaMode: 'parse',
    },
    async (input) => {
      return { input, bar: 'bar' };
    }
  );

  const result = await testFlow({} as any);

  assert.deepStrictEqual(result, {
    bar: 'bar-transformed',
    input: {
      foo: 'default foo',
    },
  });

also can set schemaMode: 'none', this might be useful in production mode to improve performance in case of large inputs/outputs.

Checklist (if applicable):

@pavelgj pavelgj marked this pull request as draft September 14, 2025 18:52
@github-actions github-actions bot added the js label Sep 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant