Skip to content

Recover background memory updates after transient timeouts - #1901

Merged
santoshkumarradha merged 6 commits into
devfrom
fix/memory-timeout-recovery
Oct 22, 2026
Merged

santoshkumarradha merged 6 commits into
devfrom
fix/memory-timeout-recovery

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

A stalled background memory request could consume all 45 seconds, leaving its fallback no time and dropping the exchange. Reserve half the remaining deadline for the configured small-work model, then retry the original exchange once after two seconds if the pass still fails transiently. The chat stays responsive and successful recovery saves normally without a failure notice.

Cancellation stops recovery; permanent failures do not cause repeated requests. Exhausted recovery retains the technical journal record and explains the direct /remember path. Pending exchanges remain owned by the open chat and are not persisted across restarts. The system prompt now acknowledges automatic capture instead of incorrectly claiming /remember is required.

Proof

The real terminal acceptance test TestMemoryRecoversFromTimeoutOnTheRealTerminal passed on 7a6ed127d3e5e70a53f73ad524ad323cb8c6fd9c in 106.58 seconds using OpenRouter deepseek/deepseek-v4.1-flash for every model role. All data below are fictional:

  1. Two injected memory-request stalls exhausted the first 45-second pass while the chat answered normally.
  2. A later background attempt saved the original weekend-envelope convention exactly once, without another user message.
  3. A fresh chat recalled it. A natural-language correction replaced violet with copper envelopes.
  4. Another fresh chat used the corrected convention to create packaging.json with {"weekend_envelope_color":"copper"}.
  5. All 26 observed requests and 51 model-log receipt rows named the exact requested model. Recovered saves displayed no terminal failure notice.

Reproduce after make build with an OpenRouter key configured:

CODEAF_E2E_MODEL=deepseek/deepseek-v4.1-flash go test -tags e2e ./internal/e2e -run '^TestMemoryRecoversFromTimeoutOnTheRealTerminal$' -count=1 -timeout 8m -v

Focused regressions also cover the exact 22.5-second primary / 45-second overall deadline split, same-model recovery, cancellation, bounded exhaustion, technical journal retention, direct manual saving after exhaustion, and session-close lifecycle. Reflex tests pass under the race detector. make pr-ready passed: build, vet, manual gates, structural laws and all affected-package tests (including all eight session shards). All seven GitHub check/status results passed on the tested head: PR gate.

@santoshkumarradha
santoshkumarradha marked this pull request as ready for review October 22, 2026 22:16
@santoshkumarradha
santoshkumarradha merged commit ed7fe43 into dev Oct 22, 2026
7 checks passed
@santoshkumarradha
santoshkumarradha deleted the fix/memory-timeout-recovery branch October 22, 2026 22:29
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.

1 participant