Skip to content

fix(llm): give a truncated structured-output retry one more attempt - #619

Closed
zzwong wants to merge 4 commits into
mainfrom
fix/rollup-truncated-response-retry
Closed

zzwong wants to merge 4 commits into
mainfrom
fix/rollup-truncated-response-retry

Conversation

@zzwong

@zzwong zzwong commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Parked. Not ready for review.

When a structured-output retry still decodes as incomplete JSON (io.EOF / io.ErrUnexpectedEOF), give it one more independently sampled attempt instead of failing the task. A retry that fails on a real schema violation keeps the current two-attempt budget. Adds tests in internal/llm/adapter_test.go.

Before this goes up for review, confirm the failure still happens in live runs.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Repo scaffolding / maintenance

Checklist

  • I have read the contributing guide
  • My change follows the project structure and conventions
  • make tidy passes
  • make lint passes
  • make test passes
  • make build passes

Related Issues

Closes #618

zzwong added 4 commits August 20, 2026 18:32
A live run's structured-output task can fail both its initial attempt
and its single validation retry with the same decode error class: the
response stops before a complete JSON value is written (io.EOF or
io.ErrUnexpectedEOF from the strict decoder), rather than a well-formed
value that fails schema validation. In that case the standard "your
JSON was invalid" retry prompt doesn't address the real problem — the
response never finished — and the task fails outright after only two
attempts, aborting the run.

Give a response that decodes as incomplete JSON one additional,
independently-sampled attempt beyond the normal single retry. A retry
that instead fails on a genuine schema violation (complete but wrong
JSON) keeps today's two-attempt budget unchanged.
@zzwong

zzwong commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Closing as not needed for now. In 509 retained runs (Sep 13–24), a structured-output response was cut off on the first attempt twice, and the existing single retry recovered both times. The case this PR handles, where the retry is also cut off, didn't happen. Reopen if a run fails with "structured output invalid after retry" and both attempts show unexpected EOF. The branch is kept.

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.

fix(llm): retry once more when structured output is cut off mid-response

1 participant