[PR #6967] [MERGED] fix: character ID names in every chat mode, and no raw tool calls in streamed replies #7409

Closed
opened 2026-10-23 04:19:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6967
Author: @SpicyMarinara
Created: 10/2/2026
Status: ✅ Merged
Merged: 10/2/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/charid-modes-toolcall-stream


📝 Commits (10+)

  • a938678 fix(macros): name character ID macros in Conversation and Game chats
  • 94fc5b3 fix(generate): drop streamed text tool calls from the reply
  • afd69ef docs(macros): say where character ID cards are added
  • f9f96ec Merge remote-tracking branch 'origin/staging' into fix/charid-modes-toolcall-stream
  • 2ec0b0f Merge remote-tracking branch 'origin/staging' into fix/charid-modes-toolcall-stream
  • d6be6ae docs(changelog): drop repeated entries
  • 7da395d Merge remote-tracking branch 'origin/staging' into fix/charid-modes-toolcall-stream
  • 822edb1 Merge remote-tracking branch 'origin/staging' into fix/charid-modes-toolcall-stream
  • f524dc4 fix(macros): name every referenced character, not just eight
  • 8ca42f6 fix(macros): name every referenced character in Roleplay too

📊 Changes

9 files changed (+224 additions, -14 deletions)

View changed files

📝 CHANGELOG.md (+4 -0)
📝 docs/prompts/macros.md (+1 -1)
📝 packages/server/src/routes/chats.routes.ts (+1 -0)
📝 packages/server/src/routes/generate.routes.ts (+8 -0)
📝 packages/server/src/routes/generate/dry-run-route.ts (+7 -0)
📝 packages/server/src/services/prompt/macro-context.ts (+35 -12)
➕ scripts/regressions/character-id-macro-modes.regression.ts (+154 -0)
📝 scripts/regressions/gm-skill-check-resolution.regression.ts (+5 -1)
📝 scripts/regressions/roleplay-function-calling.regression.ts (+9 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #6956
Closes #6951

One commit per issue, plus a small docs fix.

Why this change

  • #6956: {{<character ID>}} became a name only in Roleplay chats that use a prompt preset. Only that path built the ID-to-name map, so in Conversation and Game chats the macro stayed as raw text.
  • #6951: With streaming on, a model that writes tool calls as text (like KoboldCPP/Gemma) left the raw <tool_call>{…}</tool_call> at the top of the saved reply, even though the call ran. The text was streamed and added to the reply before the call was recognized, and nothing removed it afterwards.

What changed

Character ID names everywhere (#6956)

  • The existing buildReferencedCharacterContext helper gets a namesOnly option that skips card text and lorebook scans.
  • Whenever the Roleplay preset assembler isn't building the prompt, generation, the dry run and Peek Prompt's preview use it to fill in names.
  • Which cards get added to the prompt doesn't change. Only Roleplay chats with a preset add the referenced card, and docs/prompts/macros.md now says so.
  • Not covered: an ID that appears only inside an activated lorebook entry still stays raw outside Roleplay with a preset, because only that path re-reads activated lorebooks.

No more raw tool call text (#6951)

  • When a round returns tool calls but no text after text was streamed, that round's text is dropped from the reply.
  • The client gets its existing content_replace event, so the raw call disappears from the screen too.
  • Native tool calls and non-streaming replies are unaffected. Any prose written in the same round as a text tool call is dropped too, which is what streaming off already does.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

What I ran (not a replacement for the checklist):

  • Checks: pnpm check, pnpm regression:prompt and pnpm smoke:ui (7/7) pass. I re-ran pnpm check and the four related regressions after merging the latest staging.

  • New character-id-macro-modes.regression.ts: checks Peek Prompt, the dry run and the sent prompt in Conversation and Game. It fails before the fix, and also with either half of the fix undone.

  • Extended roleplay-function-calling.regression.ts: the saved reply, and the text after replaying the stream the way the client does, must both be exactly "The die settles.". Before the fix both started with the raw <tool_call>.

  • gm-skill-check-resolution.regression.ts: it looked for the first content_replace in generate.routes.ts, which is now the new one, so it's pointed at the final one again. It still guards the same thing.

  • Local CodeRabbit: 0 findings.

To check by hand:

  • Put another character's ID in a Conversation or Game chat as {{ID}} and check Peek Prompt shows their name.
  • With a local model that writes <tool_call> text and streaming on, have a character roll dice. The reply should show only the narration, with no raw tag, both while streaming and after reload.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

docs/prompts/macros.md has one corrected paragraph. The translated packs will follow in a docs-i18n PR with #6966's doc change.

UI evidence (if applicable)

Server-side changes; the client reuses its existing content-replace handling.

Summary by CodeRabbit

  • Bug Fixes
    • Text streamed as a tool call is removed from displayed and saved replies when the call produces no content.
    • Character-ID macros resolve to names in Conversation and Game chats, and in Roleplay chats without a prompt preset. In Roleplay chats with a preset, they can also include the referenced character’s fields in the system prompt.
    • Fixed NanoGPT GLM reasoning behavior when Reasoning Effort is Off.
  • New Features
    • Android users can access the camera when picking pictures.

🔄 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/6967 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/2/2026 **Status:** ✅ Merged **Merged:** 10/2/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/charid-modes-toolcall-stream` --- ### 📝 Commits (10+) - [`a938678`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a9386785224fde7d86419ff58e29ffd88b8f33d8) fix(macros): name character ID macros in Conversation and Game chats - [`94fc5b3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/94fc5b355e1a2f8f229b1cd84d8daf4787b758be) fix(generate): drop streamed text tool calls from the reply - [`afd69ef`](https://github.com/Pasta-Devs/Marinara-Engine/commit/afd69ef3cda03a14f2615340ac219e75971b12d2) docs(macros): say where character ID cards are added - [`f9f96ec`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f9f96ec16059242a893c06cb23485fe9f08d78ab) Merge remote-tracking branch 'origin/staging' into fix/charid-modes-toolcall-stream - [`2ec0b0f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2ec0b0f9a9d44862bb2dab6cc7e35f947a9ea62d) Merge remote-tracking branch 'origin/staging' into fix/charid-modes-toolcall-stream - [`d6be6ae`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d6be6aee8303355c57c340af8cd10872c2eb7b25) docs(changelog): drop repeated entries - [`7da395d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7da395d5f29f7983ca082a37e495e7244bb1900a) Merge remote-tracking branch 'origin/staging' into fix/charid-modes-toolcall-stream - [`822edb1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/822edb171b069dda3d762c0c8d93d8dd8ccf8a29) Merge remote-tracking branch 'origin/staging' into fix/charid-modes-toolcall-stream - [`f524dc4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f524dc43c763d05011afb9a611a317d686fbffb3) fix(macros): name every referenced character, not just eight - [`8ca42f6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8ca42f6409ac5747a783af03e17a3206df68bbbf) fix(macros): name every referenced character in Roleplay too ### 📊 Changes **9 files changed** (+224 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -0) 📝 `docs/prompts/macros.md` (+1 -1) 📝 `packages/server/src/routes/chats.routes.ts` (+1 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+8 -0) 📝 `packages/server/src/routes/generate/dry-run-route.ts` (+7 -0) 📝 `packages/server/src/services/prompt/macro-context.ts` (+35 -12) ➕ `scripts/regressions/character-id-macro-modes.regression.ts` (+154 -0) 📝 `scripts/regressions/gm-skill-check-resolution.regression.ts` (+5 -1) 📝 `scripts/regressions/roleplay-function-calling.regression.ts` (+9 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #6956 Closes #6951 One commit per issue, plus a small docs fix. ## Why this change - **#6956:** `{{<character ID>}}` became a name only in Roleplay chats that use a prompt preset. Only that path built the ID-to-name map, so in Conversation and Game chats the macro stayed as raw text. - **#6951:** With streaming on, a model that writes tool calls as text (like KoboldCPP/Gemma) left the raw `<tool_call>{…}</tool_call>` at the top of the saved reply, even though the call ran. The text was streamed and added to the reply before the call was recognized, and nothing removed it afterwards. ## What changed **Character ID names everywhere (#6956)** - The existing `buildReferencedCharacterContext` helper gets a `namesOnly` option that skips card text and lorebook scans. - Whenever the Roleplay preset assembler isn't building the prompt, generation, the dry run and Peek Prompt's preview use it to fill in names. - Which cards get added to the prompt doesn't change. Only Roleplay chats with a preset add the referenced card, and `docs/prompts/macros.md` now says so. - Not covered: an ID that appears only inside an activated lorebook entry still stays raw outside Roleplay with a preset, because only that path re-reads activated lorebooks. **No more raw tool call text (#6951)** - When a round returns tool calls but no text after text was streamed, that round's text is dropped from the reply. - The client gets its existing `content_replace` event, so the raw call disappears from the screen too. - Native tool calls and non-streaming replies are unaffected. Any prose written in the same round as a text tool call is dropped too, which is what streaming off already does. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes What I ran (not a replacement for the checklist): - **Checks:** `pnpm check`, `pnpm regression:prompt` and `pnpm smoke:ui` (7/7) pass. I re-ran `pnpm check` and the four related regressions after merging the latest staging. - **New `character-id-macro-modes.regression.ts`:** checks Peek Prompt, the dry run and the sent prompt in Conversation and Game. It fails before the fix, and also with either half of the fix undone. - **Extended `roleplay-function-calling.regression.ts`:** the saved reply, and the text after replaying the stream the way the client does, must both be exactly "The die settles.". Before the fix both started with the raw `<tool_call>`. - **`gm-skill-check-resolution.regression.ts`:** it looked for the first `content_replace` in `generate.routes.ts`, which is now the new one, so it's pointed at the final one again. It still guards the same thing. - **Local CodeRabbit:** 0 findings. To check by hand: - Put another character's ID in a Conversation or Game chat as `{{ID}}` and check Peek Prompt shows their name. - With a local model that writes `<tool_call>` text and streaming on, have a character roll dice. The reply should show only the narration, with no raw tag, both while streaming and after reload. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) `docs/prompts/macros.md` has one corrected paragraph. The translated packs will follow in a `docs-i18n` PR with #6966's doc change. ## UI evidence (if applicable) Server-side changes; the client reuses its existing content-replace handling. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Text streamed as a tool call is removed from displayed and saved replies when the call produces no content. * Character-ID macros resolve to names in Conversation and Game chats, and in Roleplay chats without a prompt preset. In Roleplay chats with a preset, they can also include the referenced character’s fields in the system prompt. * Fixed NanoGPT GLM reasoning behavior when Reasoning Effort is Off. * **New Features** * Android users can access the camera when picking pictures. <!-- 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-23 04:19:29 +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#7409
No description provided.