Skip to content

fix(context-pivot): reset pending state on session start - #747

Open
outlier27-cell wants to merge 8 commits into
openpi-dev:mainfrom
outlier27-cell:fix/issue-746-context-pivot-session-reset
Open

outlier27-cell wants to merge 8 commits into
openpi-dev:mainfrom
outlier27-cell:fix/issue-746-context-pivot-session-reset

Conversation

@outlier27-cell

@outlier27-cell outlier27-cell commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #746. A pivot pending in an old Session could retain an in-progress flag after Pi started a replacement Session. Old progress status and failure callbacks could also appear in the replacement Session.

Value

A replacement Session can immediately start an eligible pivot, while stale callbacks cannot change its state, continuation, UI status, notifications, or headless error output.

Approach

Preserve contributor history and merge current main f98d6a4737461ba8d8ee100f113b5a7c3a0001a0, retaining main's context-based Session-start tool visibility. Invalidate the existing generation and clear pending/compacting state and status at native Session start. Reject old onError callbacks before any effect, matching the existing completion guard. Keep Pi's native compaction lifecycle, threshold, brief, and summary semantics.

Validation

Final head: 65b0e14. Local macOS, Node v26.8.1 / Bun 1.3.14:

  • bun install --frozen-lockfile: passed.
  • Focused context-pivot and tool-surface integration tests: 16 passed.
  • bun run check: passed.
  • bun run test: passed; Node 2,452 passed / 9 skipped, UI 1,338 passed in 88 files.
  • Deterministic before/after probe: old status/error reproduced before repair; afterward stale success/error produce no continuation or notification, and B's brief remains intact. UI and headless regressions also retain B's concurrency guard and current failure/retry behavior.
  • Native Pi 1.1.0 component smoke: isolated source, actual /context-pivot rejects at zero tokens before and after native /new; clean exit. No model call made. The component was explicitly loaded from this checkout, with unrelated package extensions excluded.
  • git diff --check: passed.

Live provider compaction and whole-package native UI acceptance were not performed. Pending callback isolation is established by deterministic regression/probe evidence; native smoke establishes real Session context/command compatibility. Fresh final-head CI remains separate. The first check caught a test-only TypeScript narrowing issue; the equivalent empty-array length assertion was applied before the final focused/check/test rerun.

Two independent final source reviews passed on this exact head. Final-head CI run 38696999683 passed all runtime, UI, Web E2E, and Windows background-terminal checks. Independent last-push approval still gates merge.

Impact

  • User-visible behavior: stale prior-Session pivot state/status/errors disappear; eligible replacement pivots are no longer rejected.
  • Model-visible context/tools: retains main's existing token-based tool visibility; no schema or instructions change.
  • Runtime/lifecycle: extends the existing generation ownership check and native Session reset. No scheduler or extra cancellation mechanism.
  • Persisted config/data: None.
  • Compatibility/risk: no threshold, summary, or same-Session compaction semantic changes; reversible with a code revert.

@outlier27-cell

Copy link
Copy Markdown
Contributor Author

@tt-a1i 请审核此 PR。最新提交的 GitHub CI 已全部通过;会话切换待处理状态的回归已验证,现仅等待维护者审核。

@outlier27-cell

Copy link
Copy Markdown
Contributor Author

@testikun @tt-a1i 请审核此 PR。最新提交的 CI 已通过,当前仅等待维护者审核与合并。

tt-a1i
tt-a1i previously approved these changes Oct 13, 2026

@tt-a1i tt-a1i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed head: 4b0a50a293f759bcfa9257ded629f07e77f05784 against main a18f457687b45c877bc8a15d689a7580c4f0659a.

Standards: no confirmed code-level blocker in the scoped change.

Spec: the inspected change matches the stated behavior in this PR. Integrate the two context-pivot Session-start changes together and retain both state/visibility regressions.

Validation: node --test --experimental-strip-types tests/extensions/context-pivot/index.test.ts: exit=0; ℹ tests 6; ℹ pass 6; ℹ fail 0; ℹ skipped 0

The unchanged-head focused receipts are reused after a live head/main refresh; #718 uses this round's latest-head tests. This code review does not claim installed-runtime, live-provider, full merged-queue or visual acceptance. No merge is authorized by this review.

@tt-a1i

tt-a1i commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Thanks! This was approved, but after the related fixes merged today (#745 / #739, #751, #753) it now conflicts with main. Could you rebase or merge main and resolve the conflict? I'll merge once CI is green on the updated head.

This branch has not been deployed

No deployments
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.

bug(context-pivot): reset pending pivots when sessions change

2 participants