Skip to content

fix(coding-agent): bound refinement drain during disposal and extend session-replacement timeouts - #1205

Open
MingTeer wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
MingTeer:fix/1190-new-session-refine-drain
Open

fix(coding-agent): bound refinement drain during disposal and extend session-replacement timeouts#1205
MingTeer wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
MingTeer:fix/1190-new-session-refine-drain

Conversation

@MingTeer

@MingTeer MingTeer commented Aug 11, 2026

Copy link
Copy Markdown

Summary

/new (daemon new_session command), /resume (switch_session), and fork can fail on the client with a false 30s timeout while the server is still draining in-flight continual-harness refinement during session disposal. The command actually succeeds server-side a few seconds later.

Fixes #1190.

Changes

  • Bound the refinement drain during async disposal with a 15s default budget (AgentSessionDisposeOptions.refineDrainBudgetMs); refinement is best-effort persistence, so abandoning it past the budget is preferable to stalling session replacement past client timeouts.
  • Skip starting a due-but-not-yet-started auto-refine for user-initiated session replacement (runDueRefineOnDispose: false), so /new, /resume, and fork never trigger a fresh model call while leaving a session.
  • Give new_session, switch_session, and fork a dedicated 120s client timeout instead of the generic 30s default, so a slow-but-healthy replacement never surfaces as a false client-side failure.

Tests

  • agent-connection-daemon.test.ts: replacement commands use the dedicated timeout.
  • agent-session-runtime.test.ts: session replacement passes runDueRefineOnDispose: false.
  • agent-session-serialized-refine.test.ts: drain budget bounds in-flight refinement waits; due refinement is skipped on user-initiated disposal.

Note

Bound refinement drain during session disposal and extend session-replacement timeouts

  • Adds a 15s drain budget (DEFAULT_REFINE_DISPOSE_DRAIN_BUDGET_MS) to AgentSession._drainPendingRefinementForDisposal so in-flight refinement cannot block teardown indefinitely; emits a refine-failed error if the budget is exhausted.
  • Adds AgentSessionDisposeOptions to let callers skip due auto-refine on disposal; session replacement (via AgentSessionRuntime.teardownCurrent) passes { runDueRefineOnDispose: false } to avoid starting a fresh auto-refine during user-initiated teardown.
  • Raises the client-side timeout for new_session, switch_session, and fork requests to 120s (DAEMON_SESSION_REPLACEMENT_TIMEOUT_MS) in DaemonAgentConnection, preventing false 30s timeout errors while the server drains refinement.
  • Behavioral Change: disposal that previously waited unboundedly on in-flight refinement now abandons and emits a refine-failed error after 15s (or a caller-supplied budget).

Macroscope summarized 50653d4.

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.

/new times out at 30s on the client while the server is still draining auto-refinement during session disposal

1 participant