feat: llmExtract dryRunDefaults — let workflow authors provide meaningful mock data #130

Closed
opened 2026-04-25 04:38:43 +00:00 by xiaoju · 1 comment
Owner

Problem

PR #126 fixed the crash by generating structural defaults via schemaDefaults(), but the values are semantically empty (e.g. roles: [], workflowName: ""). This can mislead moderator logic into wrong branches.

Solution

Add an optional dryRunDefaults parameter to llmExtract:

const result = await llmExtract({
  schema: analystSchema,
  dryRun: dry,
  dryRunDefaults: {
    roles: [{ name: 'greeter', task: '(dry-run)' }],
    workflowName: 'dry-run-test',
  },
});

Priority

  1. Use dryRunDefaults if provided
  2. Fall back to schemaDefaults(schema) (current behavior from #126)

Implementation

  1. Add optional dryRunDefaults?: Partial<T> to LlmExtractOptions
  2. In dryRun branch: return ok({ ...schemaDefaults(schema), ...dryRunDefaults } as T)
  3. Add test case
  4. Update workflow-generator to provide meaningful dryRunDefaults in each role

Ref: follow-up to #123 / PR #126

小橘 🍊(NEKO Team)

## Problem PR #126 fixed the crash by generating structural defaults via `schemaDefaults()`, but the values are semantically empty (e.g. `roles: []`, `workflowName: ""`). This can mislead moderator logic into wrong branches. ## Solution Add an optional `dryRunDefaults` parameter to `llmExtract`: ```typescript const result = await llmExtract({ schema: analystSchema, dryRun: dry, dryRunDefaults: { roles: [{ name: 'greeter', task: '(dry-run)' }], workflowName: 'dry-run-test', }, }); ``` ### Priority 1. Use `dryRunDefaults` if provided 2. Fall back to `schemaDefaults(schema)` (current behavior from #126) ### Implementation 1. Add optional `dryRunDefaults?: Partial<T>` to `LlmExtractOptions` 2. In dryRun branch: `return ok({ ...schemaDefaults(schema), ...dryRunDefaults } as T)` 3. Add test case 4. Update workflow-generator to provide meaningful dryRunDefaults in each role Ref: follow-up to #123 / PR #126 小橘 🍊(NEKO Team)
Author
Owner

结论:不需要额外的 dryRunDefaults 参数。

zod schema 本身支持 .default(),而 schemaDefaults()(PR #126)已经处理了 default 节点——遇到 z.xxx().default(val) 会直接取 def.defaultValue

推荐做法:workflow 作者在 schema 里给关键字段加 .default(),dryRun 自动拿到有意义的值。无需改 llmExtract API。

PR #131 已关闭。

小橘 🍊(NEKO Team)

结论:不需要额外的 `dryRunDefaults` 参数。 zod schema 本身支持 `.default()`,而 `schemaDefaults()`(PR #126)已经处理了 default 节点——遇到 `z.xxx().default(val)` 会直接取 `def.defaultValue`。 **推荐做法**:workflow 作者在 schema 里给关键字段加 `.default()`,dryRun 自动拿到有意义的值。无需改 llmExtract API。 PR #131 已关闭。 小橘 🍊(NEKO Team)
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#130