mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8865] [MERGED] fix(mari): restate hidden plans and fix OpenRouter credit/context failures #8851
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#8851
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/8865
Author: @mayhair
Created: 11/5/2026
Status: ✅ Merged
Merged: 11/5/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/mari-withheld-reply-openrouter-context📝 Commits (5)
01ccc0cfix(mari): restate withheld replies and recover from context overflow96ce63cfix(mari): cap output budget and recover from OpenRouter credit limits0d5a84dfix(mari): withheld-reply notice on the Pi runtime, output cap scoped to the model, loop regressions (review)647a886fix(mari): review follow-ups05b8f07fix(mari): retry a 402 with Max Tokens switched off at any balance📊 Changes
3 files changed (+687 additions, -28 deletions)
View changed files
📝
packages/server/src/services/professor-mari/pi-runtime.ts(+12 -8)📝
packages/server/src/services/professor-mari/workspace-agent.service.ts(+191 -20)➕
scripts/regressions/professor-mari/agent-loop-resilience.regression.ts(+484 -0)📄 Description
Closes #8866
Why this change
Two Professor Mari workspace-agent bugs reported by users:
sayis saved as her answer; earlier rounds collapse into the step timeline. When she writes the plan, then runs checks, her last round ("the original plan is still there") is all that remains as the reply, and nothing in the protocol told her this.reviewRoundClaim) and the "no commands butstop: false" path both drop a frame'ssaybefore it is shown to the user. The frame still goes into Mari's history, and nothing tells her it was withheld, so she treats the plan as already shown. Her hidden reasoning is never shown either, and the protocol didn't say so.OpenRouter API error 402: This request requires more credits, or fewer max_tokens. You requested up to 929637 tokens, but can only afford 176108.What changed
All changes are in
packages/server/src/services/professor-mari/workspace-agent.service.ts:MARI_WITHHELD_REPLY_NOTICE: added to the claim-audit repair prompt and to the no-commands/no-stop repair prompt (when that frame had asay). It tells Mari the user saw none of the previous reply and that she must restate the full plan or answer instead of pointing back to it.sayfield rule now states that hidden reasoning is never shown, that withheld replies must be restated, and that only the finalsayis kept as the answer, so a plan written before follow-up checks must be repeated there.mariMaxOutputTokensnow returns at mostMARI_MAX_OUTPUT_TOKENS(32,768). Mari's replies are short JSON command frames; the cap still leaves room for a large single write plus hidden reasoning on models that can't turn it off. Smaller configured limits are unchanged.chatCompleteWorkspace(shared by the classic and pi runtimes), up to 2 retries per call:parseAffordableMaxTokensreads "can only afford N"; Mari retries with 90% of N asmax_tokens. Below 1,024 tokens it surfaces the 402 instead.parseContextOverflowErrorrecognizes "maximum context length is N tokens",context_length_exceeded, "context … too long" and similar. Mari retries with the stated window (or 75% of the configured one), so the existing fitter trims old history.contextKind: "history". Before this, trimming removed old command results but left her replies behind, stacked back to back.scripts/regressions/professor-mari/agent-loop-resilience.regression.ts.Maintainer follow-up commits (
0d5a84d8b7,647a8866eb), after an independent review:MARI_WITHHELD_REPLY_NOTICE, andpiRuntimePromptcarries the same rule in Pi's terms. The notice no longer says "in say", since Pi has nosayfield.mariMaxOutputTokensclamps a configured or default Max Tokens to the model's known max output, which fixes values copied from the whole window. The 32,768 cap applies only to OpenRouter connections. A known model's catalog limit never lowers a value the user set within the model's real limit.agent-loop-resilience.regression.tsnow runs the real classic loop and the Pi steer path with stubbed connections. It covers the notice (present when text is withheld, absent otherwise), the 402 retry, the retry bound, abort, learned context windows across calls, the unknown-model overflow case, andcontextKind: "history"on in-run frames. 18 single mutations of the fix each fail it.Validation
scripts/regressions/professor-mari/agent-loop-resilience.regression.ts: passes.scripts/regressions/android-local-auth.regression.ts: passes.tsc --noEmit(the server'slintscript): passes, no errors.scripts/regressions/professor-mari*regressions: 28/30 pass.shell-sandboxandsandbox-secretsfail on the Termux test device on a file-move assertion in code this PR doesn't touch; please confirm they pass in CI.pnpm check/pnpm regressionnot run locally (the Termux device runs out of memory on the full build).Manual verification needed
pnpm checkpnpm regressionmoonshotai/kimi-k3.1-proand the connection's Max Tokens at its auto-filled ~943k, ask Mari a multi-step question (e.g. "read and see if there's any character called Laura"). Confirm she completes it with no 402.google/gemini-4-argon: confirm she gets past the first action and finishes.[Professor Mari] Credit limit from ... retrying with maxTokens=...and the run continues.Context overflow ... retryingand continues.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.