mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2696] [Issue]: Custom-agent cadence anchors on failed runs, blocking the agent for the full interval after a transient failure #1341
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#1341
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?
Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2696
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Custom-agent cadence (run-every-N) anchors on the most recent run regardless of success, so a single failed run resets the cadence timer and blocks the agent for its full interval — the agent doesn't retry after a transient failure. Built-in agents anchor on the last successful run and don't have this problem; the inconsistency means custom agents skip turns they should run on.
Expected behavior
A custom agent with
runInterval > 1should anchor its cadence on its last successful run (matching built-in agents), so a transient failure on one turn doesn't suppress it for the nextrunIntervalmessages.Actual behavior
userMessagesSinceLastAgentRuncallsagentsStore.getLastRunByType— the most recent run regardless of success. Pre-gen custom-agent runs are persisted by iteratingpreGenResultswith no success filter, so a failed run is saved with a validmessageId(the latest user message) and becomes the cadence anchor. On the next turn the "messages since last run" count is small (< runInterval), so the agent is gated out — even though its last successful run was much earlier or never. By contrast, the built-in cadence helpershouldSkipAgentByAssistantIntervalusesgetLastSuccessfulRunByType.How it breaks the pipeline
Code trace (staging @
b826f8f4):packages/server/src/routes/generate.routes.ts:3410-3417—userMessagesSinceLastAgentRun→getLastRunByType(:3411, success-agnostic); custom agent removed by cadence at:3446.:4967—preGenResults(all pipeline results minus KR/router, no success filter); persisted at:4978-4986withmessageId= latest user message (:4973-4976).packages/server/src/services/agents/agent-cadence.ts:37— built-inshouldSkipAgentByAssistantIntervalusesgetLastSuccessfulRunByType(the correct, success-anchored behavior).Steps to reproduce
runInterval: 3.Suggested fix
Make cadence anchor on success consistently — either use
getLastSuccessfulRunByTypeinuserMessagesSinceLastAgentRun(generate.routes.ts:3411), or only persist successful custom runs at:4978(skip results where!result.success). Pick one to match the built-in cadence semantics.Environment
b826f8f4)Additional context
Found via a systematic multi-agent audit of conditional prompt insertion. Causes custom agents to silently skip turns after a transient failure. Part of a set of conditional-injection issues filed together.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@kolacheee commented on GitHub (Jun 21, 2026):
Correction to the code trace: the built-in cadence helper is at
packages/server/src/services/generation/agent-cadence.ts:37, NOTpackages/server/src/services/agents/agent-cadence.ts— that server path does not exist and never did (verified viagit ls-tree b826f8f4; the file was already undergeneration/at the cited commit). The cited line:37and the symbolshouldSkipAgentByAssistantInterval→getLastSuccessfulRunByTypeare exactly correct; only the directory in the path is wrong.All other anchors verified in the current tree:
getLastRunByType(success-agnostic) — bug present, not fixed.!result.successfilter.saveRunstoressuccess: String(input.result.success), so a failed run persists assuccess="false".getLastRunByTypehas no success filter; :297-306getLastSuccessfulRunByTypefilterssuccess="true".getLastRunByTypehas exactly one call site (3411); every other anchor consumer already uses the success-filtered variant, so scope is complete.Recommended fix: prefer option A — change
getLastRunByTypetogetLastSuccessfulRunByTypeinuserMessagesSinceLastAgentRunat generate.routes.ts:3411. This is a one-line change that unifies custom cadence with the built-in helper and keeps failed-run diagnostics intact (success/error columns remain queryable viagetRunWithConfig). Option B (skipping persistence of failed runs at :4978) is inferior — it discards the only records wheresuccess="false"/errorare retained, which is the only reason failed runs are persisted.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in branch
codex/spicy-issue-sweep-2026-06-21.What changed:
getLastSuccessfulRunByType, matching built-in cadence behavior.Final repo checks will run after the full issue sweep.