Skip to content

fix(sessions): skip auto-resume for sessions whose history is gone - #561

Open
RonenMars wants to merge 1 commit into
mainfrom
fix/issue-483-auto-resume-history
Open

fix(sessions): skip auto-resume for sessions whose history is gone#561
RonenMars wants to merge 1 commit into
mainfrom
fix/issue-483-auto-resume-history

Conversation

@RonenMars

Copy link
Copy Markdown
Owner

Fixes #483.

The problem

Boot auto-resume spent one of its concurrency slots on every registry row it planned to resume, including rows whose provider history no longer exists on disk. Those attempts can only fail, and they fail after taking the slot — so a handful of dead rows delayed or crowded out the sessions that could actually come back.

planAutoResume() had no way to know: it checked whether the project directory still existed, but not whether the conversation history did.

The change

A bounded pre-flight pass resolves each candidate's conversation target before planning, and rows whose history is missing are skipped rather than attempted.

  • autoResumeSkipReason() is now exported so the pre-flight can cheaply drop rows that would be skipped anyway — no point resolving a target for a row already failing the age or project-exists test.
  • The pre-flight honours AUTO_RESUME_CONCURRENCY, awaiting Promise.race when the in-flight set is full, so it does not itself become an unbounded fan-out at boot.
  • A pre-flight that throws resolves to historyExists: true, deliberately preserving the existing per-attempt failure handling rather than silently converting an unknown into a skip.
  • planAutoResume() gains a historyExists predicate, defaulted to () => true so every other caller behaves exactly as before.

Codex path fixed alongside

Resolving the target surfaced a gap for Codex placeholder ids: neither the conversation lookup nor the JSONL path is keyed by the placeholder, so a Codex row could resolve no project path and be reported as history_file_missing — permanently unretryable — when its rollout was in fact present in the cache.

resolveConversationTarget() now falls back to the cached conversation meta when the row is Codex and the cached path exists on disk, feeding both projectPath and historyPath. The history_file_missing verdict now requires that fallback to have failed too.

Note historyPath is still kept separate from jsonlPath: feeding it to conversationBusy() would arm the mtime heuristic for Codex, which is the over-broad signal the original report ruled out.

Verification

tsc --noEmit clean; biome check clean across 378 files.

__tests__/auto-resume-on-boot.test.ts grows by 278 lines covering the skip path, the concurrency bound, and the Codex fallback.

A note for anyone verifying on this branch in place: it lives in a worktree under .worktrees/, where npm run lint silently checks nothing — biome ignores dot-directories, so biome check . reports "These paths were provided but ignored: ." and exits clean. The checks above were run with explicit paths.

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.

P1: boot auto-resume spends a slot on sessions that have no provider history

1 participant