[GH-ISSUE #1520] [Issue]: Malformed encounter action output silently advances combat #767

Closed
opened 2026-10-20 17:33:07 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @Romuromylus on GitHub.

During the Roleplay A13 native encounter audit on origin/refactor commit 229e7d89, malformed combat action model output was treated as a successful combat turn instead of surfacing a recoverable error.

Related smoke umbrella: #1486.

Repro

  1. In a Roleplay chat with the combat agent enabled and a deterministic local OpenAI-compatible test connection, click Encounter.
  2. Click Begin Combat.
  3. Let the model return a valid initial combat JSON object.
  4. Submit a combat action where the model response to the action request is non-JSON / malformed.

Expected

Malformed combat action output should be understandable and recoverable. The encounter should not fake a successful turn without telling the user that the model output was invalid. A reasonable result would be an inline combat error with retry/close options and unchanged combat state.

Actual

The invalid action response did not surface an error. The encounter silently used deterministic fallback action resolution, advanced combat state, and in the A13 repro ended the encounter as victory.

Because the fallback path treated the turn as successful, the combat summary path then wrote back to chat. In the deterministic repro the visible chat got an assistant summary row after the malformed action path, even though the action model output was invalid.

Evidence

Native A13 probe:

  • initial encounter rendered A13 Training Dummy, party HP, enemy HP, and custom action controls
  • normal action updated enemy/party HP and combat log as expected
  • malformed action response was A13_MALFORMED_NON_JSON_RESPONSE
  • UI did not show an invalid-output or retry error
  • encounter advanced to VICTORY
  • summary writeback occurred afterward

Code path:

  • completeJsonObject(...) catches/returns null for failed parse/LLM errors
  • resolveRoleplayEncounterAction(...) passes that through sanitizeCombatActionResult(...)
  • sanitizeCombatActionResult(...) uses fallbackActionResult(...)
  • useEncounter.sendAction(...) receives a valid-looking object and therefore does not render its AI returned an invalid response. Try again. error path

Likely Owner

src/engine/modes/roleplay/encounter/encounter-service.ts and src/features/modes/roleplay/encounter/hooks/use-encounter.ts.

The service likely needs to distinguish "sanitized malformed fields from a valid response" from "no valid response at all", so the UI can show a retryable combat error without silently inventing a successful turn.

Originally created by @Xelvanis on GitHub (May 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1520 Originally assigned to: @Romuromylus on GitHub. During the Roleplay A13 native encounter audit on `origin/refactor` commit `229e7d89`, malformed combat action model output was treated as a successful combat turn instead of surfacing a recoverable error. Related smoke umbrella: #1486. ## Repro 1. In a Roleplay chat with the `combat` agent enabled and a deterministic local OpenAI-compatible test connection, click `Encounter`. 2. Click `Begin Combat`. 3. Let the model return a valid initial combat JSON object. 4. Submit a combat action where the model response to the action request is non-JSON / malformed. ## Expected Malformed combat action output should be understandable and recoverable. The encounter should not fake a successful turn without telling the user that the model output was invalid. A reasonable result would be an inline combat error with retry/close options and unchanged combat state. ## Actual The invalid action response did not surface an error. The encounter silently used deterministic fallback action resolution, advanced combat state, and in the A13 repro ended the encounter as `victory`. Because the fallback path treated the turn as successful, the combat summary path then wrote back to chat. In the deterministic repro the visible chat got an assistant summary row after the malformed action path, even though the action model output was invalid. ## Evidence Native A13 probe: - initial encounter rendered `A13 Training Dummy`, party HP, enemy HP, and custom action controls - normal action updated enemy/party HP and combat log as expected - malformed action response was `A13_MALFORMED_NON_JSON_RESPONSE` - UI did not show an invalid-output or retry error - encounter advanced to `VICTORY` - summary writeback occurred afterward Code path: - `completeJsonObject(...)` catches/returns `null` for failed parse/LLM errors - `resolveRoleplayEncounterAction(...)` passes that through `sanitizeCombatActionResult(...)` - `sanitizeCombatActionResult(...)` uses `fallbackActionResult(...)` - `useEncounter.sendAction(...)` receives a valid-looking object and therefore does not render its `AI returned an invalid response. Try again.` error path ## Likely Owner `src/engine/modes/roleplay/encounter/encounter-service.ts` and `src/features/modes/roleplay/encounter/hooks/use-encounter.ts`. The service likely needs to distinguish "sanitized malformed fields from a valid response" from "no valid response at all", so the UI can show a retryable combat error without silently inventing a successful turn.
bsakaguchi 2026-10-20 17:33:07 +07:00
Author
Owner

@Romuromylus commented on GitHub (May 30, 2026):

Fixed by #1641, merged into refactor.

<!-- gh-comment-id:4582247135 --> @Romuromylus commented on GitHub (May 30, 2026): Fixed by #1641, merged into `refactor`.
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#767
No description provided.