Skip to content

fix: remove fabrication-inducing array guidance from validation retry prompt#50

Merged
clifton merged 1 commit into
mainfrom
fix/reask-prompt-fabrication
Jun 10, 2026
Merged

fix: remove fabrication-inducing array guidance from validation retry prompt#50
clifton merged 1 commit into
mainfrom
fix/reask-prompt-fabrication

Conversation

@clifton

@clifton clifton commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Problem

The hardcoded validation-retry ("re-ask") prompt in src/backend/utils.rs told the model:

Include multiple items (at least 2-3) in arrays of objects

This corrupts extraction results. When a response fails validation for an unrelated reason (a missing field, a wrong enum value), the retry prompt instructs the model to populate every object array with 2-3 entries — even when the source material only supports one item, or none. A model that correctly extracted a single item is explicitly told to invent more, so the retried response can be less faithful to the input than the one that failed validation.

Fix

  • Replaced the minimum-count instruction with faithfulness guidance: arrays must contain only items actually supported by the input; a single-item or empty array is valid when that is all the data supports; never invent entries to pad an array.
  • Preserved the rest of the prompt's intent unchanged: complete JSON, all required fields, exact enum values, objects (not strings) in object arrays, and correct type specifications.
  • Extracted the prompt into a validation_retry_feedback(error_message) helper so the wording is unit-testable.
  • Added test_validation_retry_feedback_does_not_induce_array_fabrication, which asserts the fabrication language ("at least 2", "2-3", "multiple items") is gone and the don't-invent guidance is present, alongside the preserved instructions.

A repo-wide grep for "2-3" / "at least 2" confirmed this was the only copy of the fabrication wording (the other hits are unrelated: multimodal test assertion messages about image counts and an example field description about summary length). No existing tests asserted the old prompt text.

Verification

  • cargo fmt — clean
  • cargo clippy --all-targets (default features, matching CI) — no warnings
  • cargo test — all 43 suites pass (143 lib unit tests plus integration/doc tests), including the new prompt test

🤖 Generated with Claude Code

… prompt

The re-ask prompt sent after a validation failure instructed the model to
"Include multiple items (at least 2-3) in arrays of objects". A model that
correctly extracted one item (or zero) from the source material was being
told to invent more, corrupting extraction results on retry.

Replace that line with guidance that arrays must contain only items
actually supported by the input — a single-item or empty array is valid —
and must never be padded with invented entries. The rest of the prompt's
intent (complete JSON, all required fields, exact enum values, objects not
strings in object arrays, correct types) is unchanged.

The prompt is extracted into a `validation_retry_feedback` helper with a
unit test asserting the fabrication language is gone and the
don't-invent guidance is present.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@clifton clifton merged commit 59f2e77 into main Jun 10, 2026
9 checks passed
@clifton clifton deleted the fix/reask-prompt-fabrication branch June 10, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant