[Bug]: Preserve completion diagnostics and recover truncated session briefs

Author: Sun-sunshine06Created Sep 17, 2026Updated Sep 17, 2026

Reproduction

While validating the current main branch on Windows with a configured compatible model endpoint, a small design generation completed and exported successfully but exposed two reliability problems:

  1. done results are compacted for streaming and again for persisted history. The second pass drops errorsPreview and resets errorCount to zero, even when status remains has_errors. This hides actionable verification feedback after restoring a session.
  2. The background design-session brief uses a fixed 2,000-token completion ceiling. When a provider reports a length stop, brief generation fails without a bounded, targeted recovery attempt; the previous brief must remain intact if recovery also fails.

A related preview issue is being checked: runtime errors from an older source document can remain visible after replacing that source.

Expected behavior

  • Repeated history compaction preserves bounded verification error previews and the total error count.
  • Brief generation has an explicit concise output contract and bounded recovery for output-token exhaustion only; authentication, cancellation and other failures must not be retried as truncation.
  • Preview error messages describe the current active document, not stale sources.

No provider credentials, private endpoint addresses or user-generated files are needed to reproduce these cases. Planned fixes will include deterministic regression tests and a changeset. The placeholder Resources page is a separate feature scope, not part of this reliability fix.

Source: OpenCoworkAI/open-codesign