mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#6668
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5192
Author: @kolacheee
Created: 8/17/2026
Status: ✅ Merged
Merged: 8/17/2026
Merged by: @kolacheee
Base:
staging← Head:feat/5183-mari-rate-limit-pause-resume📝 Commits (7)
6dd2fc5feat(mari): pause and resume Professor Mari requests on proxy rate limits (#5183)b1b491cfix(llm): keep admission slot acquisition synchronous when a connection is unthrottleddf54eb7Merge branch 'staging' of https://github.com/Pasta-Devs/Marinara-Engine into feat/5183-mari-rate-limit-pause-resume8d15237style(mari-rate-limit): apply prettier formatting to touched files092e01dfix(mari-rate-limit): address CodeRabbit review77d79cfMerge branch 'staging' into feat/5183-mari-rate-limit-pause-resume4ab0f11fix(mari-rate-limit): give the rate-limit input a programmatic aria-label (CodeRabbit)📊 Changes
20 files changed (+651 additions, -48 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/client/src/components/connections/ConnectionEditor.tsx(+41 -0)📝
packages/client/src/hooks/use-connections.ts(+1 -0)📝
packages/client/src/lib/connection-transfer.ts(+9 -0)📝
packages/client/src/localization/locales/en.json(+4 -0)📝
packages/server/src/db/schema/connections.ts(+2 -0)📝
packages/server/src/services/llm/base-provider.ts(+63 -1)📝
packages/server/src/services/llm/connection-fallback-provider.ts(+26 -14)➕
packages/server/src/services/llm/connection-rate-limit-registry.ts(+32 -0)📝
packages/server/src/services/llm/provider-registry.ts(+5 -1)📝
packages/server/src/services/llm/providers/anthropic.provider.ts(+9 -2)📝
packages/server/src/services/llm/providers/google.provider.ts(+11 -4)📝
packages/server/src/services/llm/providers/openai.provider.ts(+25 -6)➕
packages/server/src/services/llm/rate-limit-aware-provider.ts(+179 -0)📝
packages/server/src/services/professor-mari/workspace-agent.service.ts(+73 -8)📝
packages/server/src/services/storage/connections.storage.ts(+38 -11)📝
packages/shared/src/schemas/connection.schema.ts(+5 -0)📝
packages/shared/src/types/connection.ts(+2 -0)📝
packages/shared/src/types/professor-mari-workspace.ts(+1 -1)➕
scripts/regressions/rate-limit-aware-provider.regression.ts(+124 -0)📄 Description
Linked issue
Closes #5183.
Why this change
Professor Mari's agentic loop issues up to 13 back-to-back LLM requests per message (one per tool-call round,
MAX_COMMAND_ROUNDS = 12) with no delay between them. On a rate-limited proxy — the issue reports OpenRouter at five messages per minute — that trips the limit mid-task. Worse, a rate-limit error propagated straight out of the loop and the error path discarded every completed round, so the user lost the work and had to re-ask. There was no 429 handling, retry, or backoff anywhere in the LLM layer.What changed
Reactive pause & resume (always on, every connection). A new typed
LLMHttpError{status, retryAfterMs}is thrown by the OpenAI (chat/completions and Responses API), Anthropic, and Google providers so a rate-limit response is distinguishable andRetry-Afteris captured. A newRateLimitAwareProviderdecorator — installed increateLLMProviderfor direct callers and around bothconnection-fallbacklegs for the main chat/agent path — catches a 429/529 (and 503 withRetry-After), pauses (honoringRetry-After, else capped exponential backoff, bounded to 6 tries, abort-aware), and retries the same request so the task completes.Proactive per-connection throttle (opt-in). A new Max Requests Per Minute field (Settings → Connections; blank = unlimited) paces requests so a known proxy limit is never hit. It's keyed by a connection-rate-limit registry synced from the storage layer and from Professor Mari's own connection resolution, plumbed end to end (schema → type → DB column → storage create/update/clone/read/delete → client editor → import/export round-trip).
Professor Mari. Completed rounds are now persisted when a request ultimately fails (seeding a placeholder so the trace/thinking is saved even before any visible text), the pause is surfaced as a "paused, resuming in Ns…" status instead of a silent wait, and — for local-sidecar connections — the JSON command-protocol repair budget is larger (6 vs 2) and formatting-repair rounds no longer consume the command-round budget (bounded so repeated stumbles can't run unbounded). So a small local model can fumble the tool-call format a few times without starving the task.
On the separate-tool-call-model question (verify + document): Mari already resolves her connection independently (explicit picker →
defaultForAgentsrole → local-sidecar sentinel → default), so you can already point her at a local sidecar or a different connection today to offload her off your main proxy model — and that sidecar now benefits from the larger repair budget above. A first-class per-tool-round model split remains a possible future enhancement (would need its own issue).Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
pnpm checkis green (TypeScript + ESLint + localization + production build across all packages) and the newscripts/regressions/rate-limit-aware-provider.regression.tspasses — it exercises the reactive retry end to end (retry-then-succeed, non-retryable-propagates, exhaust-after-6),Retry-Afterparsing, error classification, and the registry.runtime-integrity.regression.ts, which fails only on a local Windows checkout becausepackages/server/src/assets/mlx-runtime-requirements.lockgets CRLF-normalized by autocrlf (its SHA256 then differs from the LF manifest digest); it is unrelated to this change and passes on CI's Linux runner.provider-compat.regression.tsinitially caught a real bug in an earlier revision — the decorator awaited before delegating, acquiring the admission slot a microtask late — which is fixed here (the slot is now reserved synchronously when unthrottled).version:checknot applicable.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)CHANGELOG updated under [Unreleased] → Added. The new Max Requests Per Minute connection setting is user-facing config, so a
docs/CONFIGURATION.mdnote (and itsdocs-i18nmirror) is likely warranted as a follow-up — flagging rather than checking the box.Summary by CodeRabbit
New Features
Bug Fixes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.