[GH-ISSUE #2998] [Issue]: Manual Music DJ (Spotify) retry never applies playback or the deterministic fallback in non-game chats #1572

Closed
opened 2026-10-21 05:39:28 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2998

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong
On the retry path, the only place that turns a Spotify Music DJ retry result into actual playback or applies the server-side deterministic fallback bails out for every non-game chat. The Spotify retry agent runs with tools, and its prompt explicitly permits an intent-only response. So in a roleplay/conversation manual retry, if the model returns action:"play" with track URIs but does NOT call spotify_play, nothing is queued/played — yet the client shows a "🎵 Music DJ started playback" bubble. The same intent-only result is rescued in game mode and always rescued on the main /generate route.

How to reproduce (try it yourself)

  1. Create a roleplay (non-game) chat with the Music DJ agent enabled in Spotify provider mode and a connected Spotify account/device.
  2. After a turn, manually trigger a Music DJ retry (POST /retry-agents with agentTypes including spotify, musicPlayerSource spotify, non-game chat).
  3. Have the agent model return a valid JSON intent ({action:"play", trackUris:[...]}) WITHOUT emitting a spotify_play tool call.

You'll see: the result is success/action=play, the client shows a "started playback" bubble, but no track is queued/played on Spotify.
Expected: the same deterministic fetch-and-play fallback that game mode and the main /generate flow apply.

Where it is
packages/server/src/routes/generate/retry-agents-route.ts:1820-1821 (gate inside validateSpotifyRetryPlayback, 1804-1946; sole call site at :2027). Contrast: mode-agnostic applySpotifyAgentPlaybackFallback at packages/server/src/services/generation/spotify-agent-runtime.ts:335-446, invoked unconditionally in generate.routes.ts:7700 and :7746.

What's happening
The deterministic playback validation/fallback for manual Spotify retries was scoped to game mode only (constraints.mode !== "game" early-return), but the retry agent runs in tool mode where the model may legitimately return intent-only output, and there is no roleplay-mode equivalent of the main route's unconditional fallback.

Suggested fix
Widen the gate for non-game while keeping game mode's logic intact, and only rescue the genuine gap (model returned action:"play" but never called spotify_play). Two surgical edits in retry-agents-route.ts:

  1. Line 1821 — if (!forceFreshPick) return result; (drop the || constraints.mode !== "game").
  2. Immediately after line 1825 (after spotifyPlayCalled/spotifyPlayApplied are computed), add a non-game guard so the single-track game logic never clobbers a correctly-queued roleplay result:
  if (constraints.mode !== "game" && spotifyPlayCalled && spotifyPlayApplied) {
    return result;
  }

This leaves the existing !spotifyPlayCalled recovery active for non-game — exactly the missing safety net. Regression avoided: do NOT simply run the full game-mode validateSpotifyRetryPlayback body for non-game (what if (!forceFreshPick) return result; alone does) — roleplay Music DJ queues MULTIPLE tracks while the validator's accept paths are single-track-only, so a correct 5-track queue would fall through to the deterministic single-track re-pick, discarding the model's queue and emitting false-failure toasts. This is the exact regression v1.6.1 fixed; the added non-game guard preserves it.


AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.

Originally created by @kolacheee on GitHub (Jun 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2998 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** On the retry path, the only place that turns a Spotify Music DJ retry result into actual playback or applies the server-side deterministic fallback bails out for every non-game chat. The Spotify retry agent runs with tools, and its prompt explicitly permits an intent-only response. So in a roleplay/conversation manual retry, if the model returns `action:"play"` with track URIs but does NOT call spotify_play, nothing is queued/played — yet the client shows a "🎵 Music DJ started playback" bubble. The same intent-only result is rescued in game mode and always rescued on the main /generate route. **How to reproduce (try it yourself)** 1. Create a roleplay (non-game) chat with the Music DJ agent enabled in Spotify provider mode and a connected Spotify account/device. 2. After a turn, manually trigger a Music DJ retry (POST /retry-agents with agentTypes including spotify, musicPlayerSource spotify, non-game chat). 3. Have the agent model return a valid JSON intent (`{action:"play", trackUris:[...]}`) WITHOUT emitting a spotify_play tool call. You'll see: the result is success/action=play, the client shows a "started playback" bubble, but no track is queued/played on Spotify. Expected: the same deterministic fetch-and-play fallback that game mode and the main /generate flow apply. **Where it is** `packages/server/src/routes/generate/retry-agents-route.ts:1820-1821` (gate inside `validateSpotifyRetryPlayback`, 1804-1946; sole call site at :2027). Contrast: mode-agnostic `applySpotifyAgentPlaybackFallback` at `packages/server/src/services/generation/spotify-agent-runtime.ts:335-446`, invoked unconditionally in `generate.routes.ts:7700` and `:7746`. **What's happening** The deterministic playback validation/fallback for manual Spotify retries was scoped to game mode only (`constraints.mode !== "game"` early-return), but the retry agent runs in tool mode where the model may legitimately return intent-only output, and there is no roleplay-mode equivalent of the main route's unconditional fallback. **Suggested fix** Widen the gate for non-game while keeping game mode's logic intact, and only rescue the genuine gap (model returned action:"play" but never called spotify_play). Two surgical edits in retry-agents-route.ts: 1. Line 1821 — `if (!forceFreshPick) return result;` (drop the `|| constraints.mode !== "game"`). 2. Immediately after line 1825 (after `spotifyPlayCalled`/`spotifyPlayApplied` are computed), add a non-game guard so the single-track game logic never clobbers a correctly-queued roleplay result: ```ts if (constraints.mode !== "game" && spotifyPlayCalled && spotifyPlayApplied) { return result; } ``` This leaves the existing `!spotifyPlayCalled` recovery active for non-game — exactly the missing safety net. Regression avoided: do NOT simply run the full game-mode `validateSpotifyRetryPlayback` body for non-game (what `if (!forceFreshPick) return result;` alone does) — roleplay Music DJ queues MULTIPLE tracks while the validator's accept paths are single-track-only, so a correct 5-track queue would fall through to the deterministic single-track re-pick, discarding the model's queue and emitting false-failure toasts. This is the exact regression v1.6.1 fixed; the added non-game guard preserves it. --- *AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.*
Author
Owner

@SpicyMarinara commented on GitHub (Jun 29, 2026):

Fixed in merged staging PR #3004.

<!-- gh-comment-id:4832283044 --> @SpicyMarinara commented on GitHub (Jun 29, 2026): Fixed in merged staging PR #3004.
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#1572
No description provided.