Skip to content

Stabilize provisional thought labels during streaming - #665

Merged
marksftw merged 1 commit into
masterfrom
codex/issue-660-provisional-thought-snapshots
Jul 24, 2026
Merged

Stabilize provisional thought labels during streaming#665
marksftw merged 1 commit into
masterfrom
codex/issue-660-provisional-thought-snapshots

Conversation

@marksftw

Copy link
Copy Markdown
Contributor

Closes#660

Follow-up to #646 and #650.

Why

Long active reasoning phases could remain on Thinking... because every streamed reasoning delta invalidated and aborted the in-flight Gemma request before it could return.

That strict behavior came from a valid review concern: a result tied to older reasoning must not arrive out of order, overwrite a newer summary, or become the retained fallback. However, treating every transport update as a new authoritative snapshot made provisional labels effectively impossible during continuous streaming. Allowing every timed result to publish solved that starvation but made the label change too often to read comfortably.

This PR uses bounded sampled generations as the compromise: streaming text continues to accumulate, while only deliberate label checkpoints supersede an in-flight request.

What changed

  • Keep live reasoning updates buffered without cancelling the current sampled request.
  • Try an initial provisional label after one second and use the five-second checkpoint only when no provisional has succeeded.
  • Allow one intentional refresh after fifteen seconds when the reasoning has changed, then let the completed-phase label remain authoritative.
  • Abort an older request when a newer sampled generation, task context, thought phase, or lifecycle transition supersedes it.
  • Guard every commit by phase, generation, controller, and sampled content so late results cannot overwrite newer work.
  • Retain an accepted provisional if completion cancels a pending fifteen-second refresh.

The usual visible progression is now Thinking... → early provisional → optional fifteen-second refresh → final label. Prompting, model selection, persistence, privacy boundaries, and label validation are unchanged.

Validation

  • bun test — 206 passing
  • bun run typecheck
  • bun run lint — 0 errors, 12 existing warnings
  • bun run format:check

The desktop binary was not built.

@marksftw
marksftwforce-pushed the codex/issue-660-provisional-thought-snapshots branch from 8203063 to 3129e86CompareJuly 23, 2026 21:31
@cloudflare-workers-and-pages

cloudflare-workers-and-pagesBot commented Jul 23, 2026

Copy link
Copy Markdown

Deploying maple with Cloudflare Pages Cloudflare Pages

Latest commit:3129e86
Status: ✅ Deploy successful!
Preview URL:https://feeca148.maple-ca8.pages.dev
Branch Preview URL:https://codex-issue-660-provisional.maple-ca8.pages.dev

View logs

@marksftw

Copy link
Copy Markdown
ContributorAuthor

Post-rebase code review is complete. I reviewed the change independently from race/lifecycle, simplicity/privacy, and UX/test-coverage angles, then validated the findings locally. No code changes were warranted.

The snapshot/request guards keep older results from overwriting newer labels, lifecycle cleanup remains deterministic, and the implementation stays narrowly scoped without reintroducing persistence or development diagnostics. I also checked the early-failure/no-retry behavior and synthetic same-phase replacement behavior; both are consistent with the intended lifecycle and do not justify additional complexity in this small follow-up.

Validation is clean: 214 tests passed, typecheck and formatting passed, lint reported 0 errors (12 existing warnings), and git diff --check passed.

@marksftw

marksftw commented Jul 23, 2026

Copy link
Copy Markdown
ContributorAuthor

Ready for review. Tested and feeling good about the UX for this. Labels are generated quickly. There is a 5 second retry if it fails. And then longer reasoning blocks get an updated label at 15 seconds because they have more understanding by that point.

@marksftw
marksftw marked this pull request as ready for review July 23, 2026 23:06

@AnthonyRonningAnthonyRonning left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. This is a focused, maintainable follow-up that stabilizes provisional thought labels during streaming, including lifecycle and cancellation handling, without adding persistence or unrelated scope. The review found no blocking issues. One minor retry edge case—unchanged reasoning after an early label request failure—can be handled later; it only leaves the generic “Thinking…” state and does not risk stale or incorrect labels. You can merge whenever you are ready.

@marksftw
marksftw merged commit 4e8d0ac into masterJul 24, 2026
16 checks passed
@marksftw
marksftw deleted the codex/issue-660-provisional-thought-snapshots branch July 24, 2026 14:28
Sign up for freeto 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.

Allow provisional thought labels during continuous reasoning

2 participants

@marksftw@AnthonyRonning