Skip to content

isValueEmpty treats tables with template rows as non-empty, preventing LLM from filling them #160

Description

@jlevy

Bug

isValueEmpty for tables only checks rows.length > 0, so tables with
pre-seeded template/hint rows (e.g., | EPS | | | | |) are classified as
"answered." The fill harness then never generates an issue for these fields,
and the LLM never attempts to fill them.

Reproduction

Given a form with a table field containing template rows:

{% field kind="table" id="earnings_results" label="Earnings Results"
   columnIds=["metric", "actual", "estimate", "surprise", "notes"]
   columnTypes=["string", "number", "number", "string", "string"] %}

| Metric  | Actual | Estimate | Surprise | Notes |
| ------- | ------ | -------- | -------- | ----- |
| EPS     |        |          |          |       |
| Revenue |        |          |          |       |

{% /field %}
  1. Parse the form and check formProgress — the earnings_results field
    shows as "answered" despite all data cells being empty
  2. Run a fill — the LLM never receives an issue for this field and never
    attempts to fill it
  3. Result: all cells remain empty, but progress reports the field as filled

Root cause

// parseFields.ts:93-94
case 'table':
  return (value.rows?.length ?? 0) === 0;

This cascades through:

  1. isValueEmptyfalse (template rows count as rows)
  2. createFieldResponse{ state: "answered" }
  3. addOptionalUnansweredIssues → skips field (not "unanswered")
  4. LLM never sees the table → all cells remain empty/skipped

Impact

Any form with pre-seeded table rows gets 100% empty tables that
formProgress reports as "filled." Silent failure, no errors or warnings.

Suggested fix

isValueEmpty should check whether rows contain actual data, not just
whether rows exist:

case 'table': {
  const rows = value.rows ?? [];
  if (rows.length === 0) return true;
  return rows.every(row =>
    row.cells.every(cell => cell.state === 'skipped' || cell.state === 'empty')
  );
}

Ref: dxdt-labs/ai-trade-arena#381

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions