Skip to content

🤖 fix: keep compaction identity across startup auto-retry - #3945

Open
coadler wants to merge 1 commit into
mainfrom
fix/compaction-startup-retry-identity
Open

🤖 fix: keep compaction identity across startup auto-retry#3945
coadler wants to merge 1 commit into
mainfrom
fix/compaction-startup-retry-identity

Conversation

@coadler

@coadler coadler commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Startup auto-retry of an interrupted compaction lost the compaction-request metadata, so the resumed stream was no longer tracked as a compaction. The model's summary reply became a plain assistant response and the chat never compacted.

Background

When a stream is interrupted (crash, restart), deriveStartupAutoRetryRequest rebuilds send options from persisted state. Its compaction branch rebuilt model/agentId/toolPolicy but dropped muxMetadata, because StartupRetrySendOptions.muxMetadata only allowed workspace-turn-task metadata.

On resume, resolveCompactionRequest scans history backward for the compaction-request row. Without the stream identifying as a compaction request, any trailing synthetic user row — a <system-file-update> file-change notice or the [CONTINUE] sentinel — aborts the scan. activeCompactionRequest stayed undefined, compactionHandler.handleCompletion treated the stream-end as a normal turn, and no boundary summary was written.

Implementation

  • Widen StartupRetrySendOptions.muxMetadata to also accept { type: "compaction-request" }.
  • In the compaction branch of deriveStartupAutoRetryRequest, carry the original muxMetadata through so the resumed stream still identifies itself; resolveCompactionRequest then resolves via the options path regardless of trailing synthetic rows.

Validation

  • New regression test seeds durable history with a compaction-request row plus a trailing synthetic row, runs the real startup auto-retry path (scheduleStartupAutoRetryIfNeeded), and asserts the boundary lands. Fails before the fix, passes after.
  • Added a control test proving plain synthetic agent-initiated sends (the parent-to-child guidance path) compact correctly end-to-end.
  • Added a characterization test documenting that family-payload (preTurnMessages) sends intentionally skip on-send compaction.
  • make static-check, targeted compaction suites green. Full src/node/services run shows only failures verified pre-existing on the pristine baseline (unrelated hooks/browser suites).

Risks

Low. The metadata now flows through the same option field resumeStream already consumes; normalizeGatewaySendOptions spreads it through untouched. The widened union is additive: existing workspace-turn-task behavior is unchanged, and non-compaction retries never set the field.


Generated with xum • Model: openrouter:stealth/ox-alpha • Thinking: high • Cost: $0.04

deriveStartupAutoRetryRequest rebuilt send options for an interrupted
compaction without muxMetadata, so the resumed stream no longer
identified as a compaction request. resolveCompactionRequest then
aborted its backward scan at any trailing synthetic row (file-change
notice, [CONTINUE] sentinel), activeCompactionRequest stayed undefined,
and the model's summary was recorded as a plain assistant response
instead of collapsing history at a compaction boundary.

Carry the original compaction-request metadata through startup retry
options and add a regression test covering the interrupted-compaction
resume path plus characterization tests for synthetic guidance sends.

Co-authored-by: Mux <noreply@coder.com>
@coadler

coadler commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 3555414d0a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@coadler coadler changed the title fix: keep compaction identity across startup auto-retry 🤖 fix: keep compaction identity across startup auto-retry Aug 24, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 3555414d0a

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@coadler
coadler added this pull request to the merge queue Aug 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 24, 2026
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