Skip to content

Stop silently wiping Ask Lucid memory on a slow resume#110

Merged
ankitsejwal merged 1 commit into
mainfrom
fix/lucid-resume-memory-wipe
Jul 9, 2026
Merged

Stop silently wiping Ask Lucid memory on a slow resume#110
ankitsejwal merged 1 commit into
mainfrom
fix/lucid-resume-memory-wipe

Conversation

@ankitsejwal

Copy link
Copy Markdown
Member

Fixes #107.

The bug

On the Code tab, Ask Lucid would answer a follow-up with zero memory of the earlier turns — no error, nothing in the diagnostics dump. It wasn't the socket: there was no reconnect between the message that still had memory and the one that didn't.

Every turn runs claude -p --resume <sessionId>. The daemon bounded the resumed run with a 15s first-output deadline (RESUME_FIRST_OUTPUT_MS); if no first token arrived in 15s it assumed the --resume handle was dead and silently re-ran with resume: undefined — a fresh, memoryless session in the same worktree (runCodeTurn.ts, same shape for the pod ask in room/client.ts). The fresh turn answers normally and hands back a new session id that the phone adopts, so the thread is re-anchored to a session that never saw the earlier messages.

The mismatch: the phone waits 90s for a coding turn's first token (CODE_FIRST_TOKEN_TIMEOUT) because coding turns legitimately plan/read before answering — but the daemon gave up at 15s. Any resumed coding turn slow past 15s silently lost its memory. (The executor only yields on the first assistant token, so this "first-output" window is really time-to-first-token.)

The fix

Align the daemon's resume first-output deadline with the phone's per-surface first-token budget:

  • pod ask: RESUME_FIRST_OUTPUT_MS 15s → 30s (= phone DEFAULT_FIRST_TOKEN_TIMEOUT)
  • coding: new RESUME_CODE_FIRST_OUTPUT_MS = 90s (= phone CODE_FIRST_TOKEN_TIMEOUT)

We no longer abandon a resume the phone is still awaiting. A genuinely dead/pruned handle still falls back to fresh — just after this window, where the phone's own timeout + lost/recover grace already cover the wait. An ended (empty) stream still self-heals immediately as before; only a hanging handle waits out the deadline.

Tests

  • A guard test pinning the deadlines ≥ the phone budgets (prevents a silent revert to 15s).
  • A behavioral test: a resumed turn slow to its first token but within budget runs once and keeps its resume id (memory preserved) instead of retrying fresh.
  • Existing self-heal / no-loop / long-turn / abort tests still pass (48/48).

Follow-ups (filed separately)

A resumed turn was abandoned after a 15s first-output deadline and re-run
as a fresh, memoryless `claude -p` session — silently dropping the whole
conversation. Coding turns plan before their first token and the phone waits
up to 90s, so any resume slow past 15s wiped memory invisibly, with no error
and nothing in the diagnostics dump.

Align the daemon's resume first-output deadline with the phone's per-surface
first-token budget: 30s for the pod ask path, a new 90s for coding. We no
longer abandon a resume the phone is still awaiting. A genuinely dead handle
still falls back to fresh — now after the phone's own timeout + lost/recover
grace already cover the wait; an ended (empty) stream self-heals immediately
as before.
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.

Ask Lucid silently forgets the conversation when a resumed turn is slow to start

1 participant