mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2987] [Issue]: Expression/Spotify agent set to the Pre-Generation phase has its result silently dropped (never finalized or applied) #1560
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#1560
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 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2987
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
The expression sprite_change and Spotify events are always deferred until a finalize step re-emits them, but that finalize step only runs over post-generation results. The agent editor lets you move the built-in Expression (or Music DJ) agent to the Pre-Generation phase. When you do, the agent runs in phase 1, its result is deferred, and because pre-generation results are never finalized or applied, the result is silently dropped. The agent burns an LLM call every eligible turn but no sprite/playback ever reaches the client — a silent no-op.
How to reproduce (try it yourself)
You'll see: the agent executes (visible in agent-debug / token usage), but no expression/sprite event reaches the client and no sprite is applied. Same for the Music DJ (spotify) agent moved to pre_generation.
Expected: the phase change is either honored or not offered; the agent should not silently no-op.
Where it is
packages/server/src/services/generation/agent-event-dispatcher.ts:5-7,31-36(defer, phase-agnostic);packages/server/src/services/generation/spotify-agent-runtime.ts:160-162(spotify defer);packages/shared/src/types/agent.ts:25-32(normalizeAgentPhaseForTypeonly hard-locks prose-guardian/continuity);packages/client/src/components/agents/AgentEditor.tsx:1644-1646(phase selector rendered for all agents). Finalize/apply gap atpackages/server/src/routes/generate.routes.ts:7786-7791(finalize loop iterates only postResults) and postResults construction at:7665-7673.What's happening
The defer/finalize protocol assumes deferred expression/spotify events are always produced by post-processing agents whose results land in
postResults.shouldDeferExpressionAgentEvent/shouldDeferSpotifyAgentEventdefer regardless of phase, and there is no finalize path for these result types in the pre-generation phase. Because the phase selector is editable for these built-ins, a deferred event can be created that is never finalized or applied.Suggested fix
Hard-lock expression and spotify to
post_processinginnormalizeAgentPhaseForType(packages/shared/src/types/agent.ts:30), the single normalization chokepoint:Because every layer routes through this function, the one edit makes the AgentEditor phase buttons no-ops for these built-ins, coerces any already-persisted pre_generation/parallel config back to post_processing on read (agents.storage.ts:51), and keeps BUILT_IN_AGENTS consistent. No dispatcher or finalize-loop changes are needed. Do NOT thread phase into the dispatcher or duplicate the finalize/apply loops over pre-gen results — both are larger and touch the high-risk apply path, and the manifests already declare these post_processing-only. Note: this also forecloses the
parallelphase for these two, which is correct —parallelruns before mainResponse exists, and both agents need the assistant reply, soparallelwas already a broken configuration.AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in merged staging PR #3004.