Repository navigation
fix(core): recover truncated session briefs with bounded retries - #424
Merged
Merged
Conversation
Signed-off-by: Sun-sunshine06 <Sun-sunshine06@users.noreply.github.com>
Signed-off-by: Sun-sunshine06 <Sun-sunshine06@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Findings
- [Minor] The length-recovery path is only verified with a mocked
completeWithRetry, so the one integration that the feature actually depends on is untested —packages/core/src/design-context.tscatcheserr instanceof CompletionLengthErrorfromcompleteWithRetry, whilepackages/core/src/design-context.test.tsreplacescompleteWithRetrywithcompleteWithRetryMockand rejects with a hand-builtCompletionLengthError. If the real wrapper remaps/wraps provider errors (or its retry predicate re-classifies the newPROVIDER_ERROR-coded length stop as transport-retriable), the recovery either never fires in production or fires after redundant transport retries — and the deterministic tests would still pass. The live smoke in the PR body completed on its first attempt, so it does not exercise this either.
Suggested fix / next action: add one providers-level or integration test that throws a realstopReason: 'length'result throughcomplete→completeWithRetryand asserts the caller receivesCompletionLengthErrorunchanged (sameusage), confirming the wrapper rethrows it as-is and does not re-retry it. If the wrapper does wrap, theinstanceofcheck indesign-context.tsneeds to key off something that survives the wrapper (for example the errorcode/name).
Questions
- Does
completeWithRetryrethrow this error instance unchanged rather than reconstructing it as a genericCodesignError? And isPROVIDER_ERRORpart of its retriable set, givenCompletionLengthErrorkeeps that code? Confirming both is what makes the recovery bounded to a single explicit retry rather than an extra layer of transport retries.
Summary
- Review mode: initial
- The change is well-scoped and directionally sound:
CompletionLengthErrorpreservesPROVIDER_ERRORand carries only usage, the recovery is a single bounded retry (BRIEF_MAX_OUTPUT_TOKENS→BRIEF_RETRY_OUTPUT_TOKENS), usage from both attempts is summed on success, and the previous brief is retained on any failure (packages/providers/src/index.ts:488,packages/core/src/design-context.ts:518). No direct provider-SDK imports, no new dependencies, and no silent fallback were introduced; the changeset covers both touched packages. - Residual risk: on total failure the thrown error carries only the second attempt's usage, so tokens/cost from the first (truncated) attempt are not surfaced to the caller. Low impact since the operation failed and the prior brief is kept, but worth noting if callers aggregate usage for display.
- The
codex-oauth-ipc.test.tsbeforeAllwarm-up is a reasonable test-infra fix and unrelated to the brief logic. - Not found in the public repo: the
completeWithRetrybody and issue #423 acceptance criteria (PR usesRefs #423, so no closure claim to validate).
Testing
- Not run (automation). Suggested addition: an integration test at the
completeWithRetryboundary assertingCompletionLengthErrorpropagates unchanged, plus a check that the wrapper does not transport-retry a length stop.
Open-CoDesign Bot
hqhq1025
added a commit
that referenced
this pull request
Sep 17, 2026
Fix independently reproduced lifecycle, artifact, chat, comment, and tweak defects. Required CI, production main-chain validation, and three independent adversarial re-reviews passed. Preserve upstream #424. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Recover background design-session briefs that stop at the output-token ceiling, without accepting incomplete JSON or replacing the previous brief on failure.
CompletionLengthError, preserving the existingPROVIDER_ERRORcode. Only usage metadata is retained; partial response content is not exposed as a successful completion.Upstream reconciliation
During validation,
mainadvanced fromb94d715toc8a179f. This branch was rebased before publication. Upstream already fixed repeateddonediagnostic compaction and retiring obsolete preview errors, so those overlapping changes were removed rather than overwritten or duplicated. This PR now touches only the remaining brief-recovery and test-setup scope.Refs #423.
Validation
On the final branch rebased onto
c8a179f:pnpm lint— passed (588 files)pnpm typecheck— passed (10 tasks)pnpm exec turbo run test --continue=always— 2,899 passed, 2 skipped, 213 test files, no cached test resultspnpm --filter @open-codesign/desktop build— passedupdateDesignSessionBriefand the normal provider layer withgemini-3.5-flash— valid normalized JSON in about 11 seconds, 1,029 reported input tokens and 451 output tokens. This live call completed on its first attempt; forced truncation/recovery is verified by deterministic tests.Deterministic coverage includes successful length recovery, exhausting the one-retry limit, malformed JSON after recovery, preserving the prior brief, aggregating usage, and not retrying other failures as truncation.
Checklist
No visual UI changes; screenshots are not applicable. This does not implement the placeholder Resources page, disable generation timeouts, or broadly accept invalid model tool arguments.