[PR #376] [MERGED] fix(generate): execute character commands when response has no prose #4591

Closed
opened 2026-10-22 04:08:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/376
Author: @cha1latte
Created: 5/3/2026
Status: ✅ Merged
Merged: 5/3/2026
Merged by: @cha1latte

Base: main ← Head: fix/empty-response-when-only-commands


📝 Commits (1)

  • 839a1a7 fix(generate): execute character commands when response has no prose

📊 Changes

2 files changed (+15 additions, -1 deletions)

View changed files

📝 packages/client/src/hooks/use-generate.ts (+3 -0)
📝 packages/server/src/routes/generate.routes.ts (+12 -1)

📄 Description

Summary

When Professor Mari emits a bare character command (e.g. [fetch:type="character" name="Becky"]) with no surrounding prose, the empty-response guard short-circuits with "The AI returned an empty response" and the parsed command never reaches the executor. The fetch silently drops; the user just sees an error toast.

This was reproducible by asking Mari to fetch a character to copy from — see attached server log:

[generate] Parsed 1 character command(s): [ 'fetch' ]
[generate] Empty response from model for chat E869EWqcUBxWYqzUTNA34 (char: professor_mari)

Why

Bare command directives are valid output for Mari — they're tool calls. The "empty response" detector was conflating "model wrote nothing useful" with "model wrote nothing visible." Commands aren't visible but they're useful.

Changes

  • [packages/server/src/routes/generate.routes.ts](packages/server/src/routes/generate.routes.ts): if parsedCommands.length > 0, skip the error path and return the commands so they execute. Don't save a blank assistant bubble. The truly-empty case (no prose AND no commands) still surfaces the same error.
  • [packages/client/src/hooks/use-generate.ts](packages/client/src/hooks/use-generate.ts): add a toast for the previously-silent data_fetched action (matches the existing toasts for character_created / persona_created / etc.).

Test plan

  • Manually verify in browser: ask Mari to fetch a character, then ask her to fetch the same one again in a way that triggers a bare command response — the fetch executes and a Fetched character: <name> toast appears (instead of the empty-response error).
  • Manually verify the toast also appears on a normal fetch where Mari includes prose (regression check).
image

Summary by CodeRabbit

  • New Features

    • Added user notifications indicating the type of data that has been fetched.
  • Bug Fixes

    • Enhanced handling of empty responses in conversation mode to allow commands to execute successfully when command data is present.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/376 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/3/2026 **Status:** ✅ Merged **Merged:** 5/3/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `main` ← **Head:** `fix/empty-response-when-only-commands` --- ### 📝 Commits (1) - [`839a1a7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/839a1a7226ef246a325ad8ec46728a5217df083e) fix(generate): execute character commands when response has no prose ### 📊 Changes **2 files changed** (+15 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/hooks/use-generate.ts` (+3 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+12 -1) </details> ### 📄 Description ### Summary When Professor Mari emits a bare character command (e.g. `[fetch:type="character" name="Becky"]`) with no surrounding prose, the empty-response guard short-circuits with `"The AI returned an empty response"` and the parsed command never reaches the executor. The fetch silently drops; the user just sees an error toast. This was reproducible by asking Mari to fetch a character to copy from — see attached server log: ``` [generate] Parsed 1 character command(s): [ 'fetch' ] [generate] Empty response from model for chat E869EWqcUBxWYqzUTNA34 (char: professor_mari) ``` ### Why Bare command directives are valid output for Mari — they're tool calls. The "empty response" detector was conflating "model wrote nothing useful" with "model wrote nothing visible." Commands aren't visible but they're useful. ### Changes - [[packages/server/src/routes/generate.routes.ts](https://claude.ai/epitaxy/packages/server/src/routes/generate.routes.ts)](packages/server/src/routes/generate.routes.ts): if `parsedCommands.length > 0`, skip the error path and return the commands so they execute. Don't save a blank assistant bubble. The truly-empty case (no prose AND no commands) still surfaces the same error. - [[packages/client/src/hooks/use-generate.ts](https://claude.ai/epitaxy/packages/client/src/hooks/use-generate.ts)](packages/client/src/hooks/use-generate.ts): add a toast for the previously-silent `data_fetched` action (matches the existing toasts for `character_created` / `persona_created` / etc.). ### Test plan - [x] Manually verify in browser: ask Mari to fetch a character, then ask her to fetch the same one again in a way that triggers a bare command response — the fetch executes and a `Fetched character: <name>` toast appears (instead of the empty-response error). - [x] Manually verify the toast also appears on a normal fetch where Mari includes prose (regression check). <img width="380" height="537" alt="image" src="https://github.com/user-attachments/assets/fc429816-21f4-4ab4-809b-800eb2975665" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added user notifications indicating the type of data that has been fetched. * **Bug Fixes** * Enhanced handling of empty responses in conversation mode to allow commands to execute successfully when command data is present. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:08:59 +07:00
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#4591
No description provided.