[GH-ISSUE #6155] Game turns that used a separate tool connection are saved as having finished with a tool call #3428

Closed
opened 2026-10-21 06:02:59 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

When a Game chat runs its tool planning on a separate connection, the finished narration is recorded with a finish reason of "tool_calls" even though the narrator ended the reply normally. You can see it in Peek Prompt, and if the narrator happens to come back empty the same wrong value is quoted back at you in the error message, pointing at a tool call that is not what stopped the reply.

How to reproduce (try it yourself)

  1. Create two connections: a Claude (Subscription) connection for narration, which reports no finish reason, and a second tool-capable connection for planning.
  2. Open a Game chat, put it on the Claude (Subscription) connection, then go to Chat Settings, Function Calling, and set "Game tool connection" to the second connection.
  3. Play a turn where the planner calls at least one tool, for example type I force the gate.
  4. Open Peek Prompt or the message details for the saved narration and look at the finish reason.

What you'll see: the finish reason reads tool_calls, even though the narration completed normally. If the narrator returns nothing at all, the error reads The AI returned an empty response (finish reason "tool_calls"). Try sending your message again.

What should happen: the field should be empty, the same as it is when you set "Game tool connection" back to "Same as narrator" and replay the same turn, and the empty-response message should read The AI returned an empty response. Try sending your message again.

Where it is

packages/server/src/routes/generate.routes.ts:

  • line 7016: result = { content: null, toolCalls: gameToolPlan.toolCalls, finishReason: "tool_calls" }, a synthesized value no provider ever reported.
  • line 7117: finishReason = result.finishReason;, then the loop breaks at :7328.
  • line 7455: finishReason = usage.finishReason ?? finishReason;, so the narrator only overwrites it when its provider reports one. Same shape at :8023 for the post-roll rewrite.
  • line 8449: persisted as extraUpdate.generationInfo.finishReason, surfaced by packages/client/src/components/chat/PeekPromptModal.tsx:44.
  • lines 8124 to 8129 feed it to describeEmptyModelResponse in packages/server/src/services/generation/empty-response-reason.ts:41-80.

packages/server/src/services/llm/providers/claude-subscription.provider.ts never reports a finish reason at all (lines 669 to 677).

What's happening

The planning pass fakes a provider result so the tool loop can carry the planned calls forward, and that fake result sets a finish reason of "tool_calls". That value is assigned to the turn's finish reason before the loop breaks, and the narrator pass only replaces it if its own provider reports one. Providers that report nothing, such as the Claude subscription transport, leave the planner's stale value in place, so it gets saved onto the message and shown to the user. Nothing branches on the value, but it is not purely cosmetic: the empty-response diagnostic quotes it verbatim, which misdirects anyone trying to work out why a turn came back blank.

Suggested fix

Do not let the narrator pass inherit the planner's synthesized finish reason. Reset the turn's finishReason to undefined when breaking out of the tool loop on the planner path, or simply do not assign the synthesized value at line 7117 in the first place, so a provider that reports nothing leaves the field empty and matches what the same chat saves on "Same as narrator".

A regression for this needs a narrator fixture that reports no finish reason and an assertion on the saved generationInfo.finishReason. The shipped game-tool-controls lane passes because its mock narrator returns finishReason: "stop", which masks the stale value.

Context

Left by merged PR #5982, which implemented feature request #5957 (running Game tool calls on a different connection than narration). It is unreleased on staging: the latest release tag is v2.4.4. PR #6137 did not touch the planner region of generate.routes.ts or the empty-response helper. The fix can ride along with the planner prompt-shape defect on this same feature, since both live in this file.

Found by an AI-assisted sweep and re-verified against staging ac14dd704 on 2026-09-13. Please verify before fixing.

Related issue from the same sweep: #6148 (the planner-path prompt shape defect the fix can ride along with).

Originally created by @kolacheee on GitHub (Sep 13, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6155 Originally assigned to: @SpicyMarinara on GitHub. When a Game chat runs its tool planning on a separate connection, the finished narration is recorded with a finish reason of "tool_calls" even though the narrator ended the reply normally. You can see it in Peek Prompt, and if the narrator happens to come back empty the same wrong value is quoted back at you in the error message, pointing at a tool call that is not what stopped the reply. ## How to reproduce (try it yourself) 1. Create two connections: a Claude (Subscription) connection for narration, which reports no finish reason, and a second tool-capable connection for planning. 2. Open a Game chat, put it on the Claude (Subscription) connection, then go to Chat Settings, Function Calling, and set "Game tool connection" to the second connection. 3. Play a turn where the planner calls at least one tool, for example type `I force the gate.` 4. Open Peek Prompt or the message details for the saved narration and look at the finish reason. **What you'll see:** the finish reason reads `tool_calls`, even though the narration completed normally. If the narrator returns nothing at all, the error reads `The AI returned an empty response (finish reason "tool_calls"). Try sending your message again.` **What should happen:** the field should be empty, the same as it is when you set "Game tool connection" back to "Same as narrator" and replay the same turn, and the empty-response message should read `The AI returned an empty response. Try sending your message again.` ## Where it is `packages/server/src/routes/generate.routes.ts`: - line 7016: `result = { content: null, toolCalls: gameToolPlan.toolCalls, finishReason: "tool_calls" }`, a synthesized value no provider ever reported. - line 7117: `finishReason = result.finishReason;`, then the loop breaks at :7328. - line 7455: `finishReason = usage.finishReason ?? finishReason;`, so the narrator only overwrites it when its provider reports one. Same shape at :8023 for the post-roll rewrite. - line 8449: persisted as `extraUpdate.generationInfo.finishReason`, surfaced by `packages/client/src/components/chat/PeekPromptModal.tsx:44`. - lines 8124 to 8129 feed it to `describeEmptyModelResponse` in `packages/server/src/services/generation/empty-response-reason.ts:41-80`. `packages/server/src/services/llm/providers/claude-subscription.provider.ts` never reports a finish reason at all (lines 669 to 677). ## What's happening The planning pass fakes a provider result so the tool loop can carry the planned calls forward, and that fake result sets a finish reason of "tool_calls". That value is assigned to the turn's finish reason before the loop breaks, and the narrator pass only replaces it if its own provider reports one. Providers that report nothing, such as the Claude subscription transport, leave the planner's stale value in place, so it gets saved onto the message and shown to the user. Nothing branches on the value, but it is not purely cosmetic: the empty-response diagnostic quotes it verbatim, which misdirects anyone trying to work out why a turn came back blank. ## Suggested fix Do not let the narrator pass inherit the planner's synthesized finish reason. Reset the turn's `finishReason` to undefined when breaking out of the tool loop on the planner path, or simply do not assign the synthesized value at line 7117 in the first place, so a provider that reports nothing leaves the field empty and matches what the same chat saves on "Same as narrator". A regression for this needs a narrator fixture that reports no finish reason and an assertion on the saved `generationInfo.finishReason`. The shipped `game-tool-controls` lane passes because its mock narrator returns `finishReason: "stop"`, which masks the stale value. ## Context Left by merged PR #5982, which implemented feature request #5957 (running Game tool calls on a different connection than narration). It is unreleased on staging: the latest release tag is v2.4.4. PR #6137 did not touch the planner region of `generate.routes.ts` or the empty-response helper. The fix can ride along with the planner prompt-shape defect on this same feature, since both live in this file. Found by an AI-assisted sweep and re-verified against staging ac14dd704 on 2026-09-13. Please verify before fixing. Related issue from the same sweep: #6148 (the planner-path prompt shape defect the fix can ride along with).
bsakaguchi 2026-10-21 06:02:59 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Sep 13, 2026):

Codex is addressing this report on behalf of @SpicyMarinara in draft PR #6168 as part of the requested issue sweep. I will verify the reported path against staging and preserve existing behavior outside the narrow fix.

<!-- gh-comment-id:5654635950 --> @SpicyMarinara commented on GitHub (Sep 13, 2026): Codex is addressing this report on behalf of @SpicyMarinara in draft PR #6168 as part of the requested issue sweep. I will verify the reported path against staging and preserve existing behavior outside the narrow fix.
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#3428
No description provided.