[PR #637] [CLOSED] serve: retry an engine start that fails, and keep the last known context after a failed restart #2734

Closed
opened 2026-11-04 02:02:44 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/637
Author: @JeanP00l
Created: 10/3/2026
Status: ❌ Closed

Base: main ← Head: pr-serve-restart


📝 Commits (1)

  • dc15468 serve: retry an engine start that fails, and keep the last known context after a failed restart

📊 Changes

2 files changed (+96 additions, -12 deletions)

View changed files

📝 serve/server.py (+41 -12)
📝 serve/test_server.py (+55 -0)

📄 Description

What

After the engine was ended mid-request (seen in long Claude Code sessions, many turns at ~20K tokens, on 2x 16 GB GPUs), the new engine could exit before READY: it ran out of VRAM while the old one's was still being handed back. restart() raised, max_context stayed 0, and from then on every request failed with 400 ... exceeds the context (0) until the server was restarted by hand.

Since 0.1.38, close() already ends the old process and waits for it. This PR adds only what is still missing.

Change (serve/server.py)

  • A start that exits before READY is tried again, 3 times, RESTART_RETRY_S (15 s) apart. starting is set meanwhile, so a request gets the 503 "starting" of #344.
  • known_ctx keeps the last context the engine reported. After a restart that failed for good, a request is checked against it and reaches run(), which starts the engine again, instead of getting a 400 about context 0.

Tests

Two new tests in RestartWindow, both fail without the change:

  • a start that fails once is retried and the engine comes up (fake engine script, retry delay patched to 0);
  • a request after a failed restart (max_context 0, not starting, known_ctx 4096) gets 200, not a 400.

python -m unittest serve.test_server: 120 tests OK (Linux, Python 3.12).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/637 **Author:** [@JeanP00l](https://github.com/JeanP00l) **Created:** 10/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr-serve-restart` --- ### 📝 Commits (1) - [`dc15468`](https://github.com/Niko1221/Strata/commit/dc15468e2bed08a8b0ba57c0214caa631fa28a6f) serve: retry an engine start that fails, and keep the last known context after a failed restart ### 📊 Changes **2 files changed** (+96 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+41 -12) 📝 `serve/test_server.py` (+55 -0) </details> ### 📄 Description ## What After the engine was ended mid-request (seen in long Claude Code sessions, many turns at ~20K tokens, on 2x 16 GB GPUs), the new engine could exit before `READY`: it ran out of VRAM while the old one's was still being handed back. `restart()` raised, `max_context` stayed 0, and from then on every request failed with `400 ... exceeds the context (0)` until the server was restarted by hand. Since 0.1.38, `close()` already ends the old process and waits for it. This PR adds only what is still missing. ## Change (serve/server.py) - A start that exits before `READY` is tried again, 3 times, `RESTART_RETRY_S` (15 s) apart. `starting` is set meanwhile, so a request gets the 503 "starting" of #344. - `known_ctx` keeps the last context the engine reported. After a restart that failed for good, a request is checked against it and reaches `run()`, which starts the engine again, instead of getting a 400 about context 0. ## Tests Two new tests in `RestartWindow`, both fail without the change: - a start that fails once is retried and the engine comes up (fake engine script, retry delay patched to 0); - a request after a failed restart (`max_context` 0, not starting, `known_ctx` 4096) gets 200, not a 400. `python -m unittest serve.test_server`: 120 tests OK (Linux, Python 3.12). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:02:44 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2734
No description provided.