Skip to content

fix(coding-agent): preserve context lifecycle and last answers - #10

Merged
fitchmultz merged 1 commit into
mainfrom
fix/context-lifecycle-fixes
Sep 7, 2026
Merged

fix(coding-agent): preserve context lifecycle and last answers#10
fitchmultz merged 1 commit into
mainfrom
fix/context-lifecycle-fixes

Conversation

@fitchmultz

Copy link
Copy Markdown
Owner

Summary

Preserve Pi's context-window behavior while fixing four lifecycle bugs:

  • Reserve an idle custom wakeup before awaiting startup guidance, so a second wakeup queues instead of racing the first.
  • Honor late Agent cancellation before committing or announcing a fresh context window.
  • Complete the early compaction phase on no-op and cancelled paths, releasing accepted input through the existing queue.
  • Keep the last answer available after rollover and resume, using only the selected branch and preserving active-message precedence and empty-answer rules.

Also remove the duplicate message-token estimator and document the empty startup-hook prompt for idle custom wakeups. No new queues, locks, cancellation controllers, transcript fields or dependency changes.

Verification

  • Exact final regression tests against the original implementation: 11 expected failures and 10 passing controls. Fixed implementation: all 21 selected cases pass.
  • Six changed test files: 108 tests pass.
  • Targeted affected and neighboring suites: 251 pass, 23 existing real-provider-gated skips.
  • npm run check passes, including types, dependency/generated-lock checks and browser bundle smoke.
  • Native Enter/Escape/queue methods run against the real session and faux provider; rendering is stubbed. File-backed SDK resume is exercised. No live clipboard, RPC process or real-provider run is claimed.

The unbuilt-worktree tests use Vite's native resolve.tsconfigPaths option in a temporary configuration to resolve existing workspace source aliases. No test configuration workaround is added to the repository.

Scope

Nine files; production agent-session.ts changes are +61/-55. Responses transport work and the Undici update are separate changes. This PR does not merge, release or activate anything in the live installation.

@fitchmultz
fitchmultz merged commit c464118 into main Sep 7, 2026
2 checks passed
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.

2 participants