[PR #8864] [MERGED] fix(dottore): ride out bursts of empty gateway replies #8852

Closed
opened 2026-11-07 17:40:13 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8864
Author: @SpicyMarinara
Created: 11/5/2026
Status: ✅ Merged
Merged: 11/5/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/dottore-gateway-patience


📝 Commits (3)

  • 15b4f18 fix(dottore): ride out bursts of empty gateway replies
  • 1a9c55c fix(dottore): give a resent reply its whole box before the deadline
  • 806b018 Merge remote-tracking branch 'origin/staging' into fix/dottore-gateway-patience

📊 Changes

3 files changed (+131 additions, -26 deletions)

View changed files

📝 .github/dottore-review/README.md (+5 -1)
📝 .github/dottore-review/dottore_review.py (+42 -9)
📝 scripts/regressions/dottore-stream-progress.regression.mjs (+84 -16)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.

Linked issue

Closes #8863

Why this change

The AI gateway in front of Dottore often ends a reply with max_tokens and no output a few seconds after the request. #8818 resends such a reply twice, after 15 s and 45 s. These replies come in bursts, so all three attempts often fail together. In run 41931881745 (PR #8837), two finder shards failed together, were resent together twice, and one failed a third time. That ended the whole review "Specimen Unexamined". The same failure ended #8841's review "Examination Incomplete" and two earlier #8837 reviews. Each rerun costs about $1.40 and 20 minutes.

What changed

  • An empty, billed gateway reply now gets two more resends, after 90 s and 120 s, on top of the existing 15 s and 45 s.
    • The extra resends run only while the resent reply still has the role's whole time box before the role's deadline, and while the review is under its cost limit. Otherwise the call fails at once without waiting.
    • Every other transient failure (overloaded, rate limited, dropped) keeps exactly two resends. A non-transient error still fails at once. A stalled stream is still resent at once, at most MODEL_MAX_RETRIES times.
  • Each transient wait is up to a third longer, by an amount fixed by the role, request key and last message. Calls that failed together no longer resend in lockstep, and a rerun waits the same. Stalls keep their 0 s wait.
  • Time a call loses to failed attempts and waits no longer counts against the role's box. Before, a finder that spent its box on resends could no longer step down one effort level when its reply hit the output cap. That step-down saved part of run 41931881745.
  • .github/dottore-review/README.md describes the new waits and limits.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Manually verify on the next few /dottore runs that a burst of "the gateway ended the reply at max_tokens before Claude wrote anything" retries shows waits of about 15, 45, 90 and 120 s in the examination log, and that the review ends with a verdict.
  • Manually verify that a review that does fail still fails within the 40-minute job limit.

Agent-run checks:

  • python3 -m py_compile .github/dottore-review/dottore_review.py: OK.
  • node ./scripts/run-regressions.mjs --filter dottore: 8 of 8 passed, after merging current staging.
  • scripts/regressions/dottore-stream-progress.regression.mjs runs chat() and run_agent() on a fake clock. It now pins the exact waits, model calls, billed prompt tokens and spend for:
    • a burst of four empty replies that then succeeds;
    • five empty replies that fail once;
    • a deadline that stops the late resends;
    • the cost limit that stops only the late resends;
    • other transient errors keeping two resends;
    • a stall resent at once, MODEL_MAX_RETRIES times;
    • parallel calls getting different waits;
    • the effort step-down still having its box after resends.
  • The new subtests fail on the reviewer before this change. Eight hand-made mutants of the new code each fail the suite.
  • Review: three independent reviewers looked at correctness, time and cost bounds, and the tests. Five findings were confirmed and fixed in the second commit: the spread used up the finder's box, the late-resend guard didn't leave the resent reply a full box, and three test gaps.

Known limits:

  • A call can now bill up to five prompts instead of three while the gateway stays bad, about $0.18 each for an uncached 140k-token finder prompt.
  • A call that will fail now takes up to about 10 minutes to fail instead of about 2.
  • ponytail: finder copies on the same packet send identical requests, so they share a spread. They already start CACHE_STAGGER_SECONDS apart.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

🤖 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/Pasta-Devs/Marinara-Engine/pull/8864 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/5/2026 **Status:** ✅ Merged **Merged:** 11/5/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/dottore-gateway-patience` --- ### 📝 Commits (3) - [`15b4f18`](https://github.com/Pasta-Devs/Marinara-Engine/commit/15b4f18a23e9cd8e158befe1a4a9ac9bf69a8a2d) fix(dottore): ride out bursts of empty gateway replies - [`1a9c55c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1a9c55ca4963f41ffc070316cee228904b3ee724) fix(dottore): give a resent reply its whole box before the deadline - [`806b018`](https://github.com/Pasta-Devs/Marinara-Engine/commit/806b018431085737c63a95f4a96984a88d8bff77) Merge remote-tracking branch 'origin/staging' into fix/dottore-gateway-patience ### 📊 Changes **3 files changed** (+131 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `.github/dottore-review/README.md` (+5 -1) 📝 `.github/dottore-review/dottore_review.py` (+42 -9) 📝 `scripts/regressions/dottore-stream-progress.regression.mjs` (+84 -16) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. ## Linked issue Closes #8863 ## Why this change The AI gateway in front of Dottore often ends a reply with `max_tokens` and no output a few seconds after the request. #8818 resends such a reply twice, after 15 s and 45 s. These replies come in bursts, so all three attempts often fail together. In run 41931881745 (PR #8837), two finder shards failed together, were resent together twice, and one failed a third time. That ended the whole review "Specimen Unexamined". The same failure ended #8841's review "Examination Incomplete" and two earlier #8837 reviews. Each rerun costs about $1.40 and 20 minutes. ## What changed - An empty, billed gateway reply now gets two more resends, after 90 s and 120 s, on top of the existing 15 s and 45 s. - The extra resends run only while the resent reply still has the role's whole time box before the role's deadline, and while the review is under its cost limit. Otherwise the call fails at once without waiting. - Every other transient failure (overloaded, rate limited, dropped) keeps exactly two resends. A non-transient error still fails at once. A stalled stream is still resent at once, at most `MODEL_MAX_RETRIES` times. - Each transient wait is up to a third longer, by an amount fixed by the role, request key and last message. Calls that failed together no longer resend in lockstep, and a rerun waits the same. Stalls keep their 0 s wait. - Time a call loses to failed attempts and waits no longer counts against the role's box. Before, a finder that spent its box on resends could no longer step down one effort level when its reply hit the output cap. That step-down saved part of run 41931881745. - `.github/dottore-review/README.md` describes the new waits and limits. ## Validation <!-- These are human tasks. Never tick a box for a check that was not actually performed. --> - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Manually verify on the next few `/dottore` runs that a burst of "the gateway ended the reply at max_tokens before Claude wrote anything" retries shows waits of about 15, 45, 90 and 120 s in the examination log, and that the review ends with a verdict. - Manually verify that a review that does fail still fails within the 40-minute job limit. Agent-run checks: - `python3 -m py_compile .github/dottore-review/dottore_review.py`: OK. - `node ./scripts/run-regressions.mjs --filter dottore`: 8 of 8 passed, after merging current staging. - `scripts/regressions/dottore-stream-progress.regression.mjs` runs `chat()` and `run_agent()` on a fake clock. It now pins the exact waits, model calls, billed prompt tokens and spend for: - a burst of four empty replies that then succeeds; - five empty replies that fail once; - a deadline that stops the late resends; - the cost limit that stops only the late resends; - other transient errors keeping two resends; - a stall resent at once, `MODEL_MAX_RETRIES` times; - parallel calls getting different waits; - the effort step-down still having its box after resends. - The new subtests fail on the reviewer before this change. Eight hand-made mutants of the new code each fail the suite. - Review: three independent reviewers looked at correctness, time and cost bounds, and the tests. Five findings were confirmed and fixed in the second commit: the spread used up the finder's box, the late-resend guard didn't leave the resent reply a full box, and three test gaps. Known limits: - A call can now bill up to five prompts instead of three while the gateway stays bad, about $0.18 each for an uncached 140k-token finder prompt. - A call that will fail now takes up to about 10 minutes to fail instead of about 2. - `ponytail:` finder copies on the same packet send identical requests, so they share a spread. They already start `CACHE_STAGGER_SECONDS` apart. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) 🤖 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-07 17:40:13 +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
Pasta-Devs/Marinara-Engine#8852
No description provided.