[PR #7222] [MERGED] fix(agents): keep Character Tracker updates returned at the result root #7630

Closed
opened 2026-10-24 04:06:01 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: staging ← Head: fix/character-tracker-root-envelope-7208


📝 Commits (3)

  • 41b555e fix(agents): keep Character Tracker updates returned at the result root
  • f82dbc7 fix(agents): keep Character Tracker no-change replies at debug level
  • a223d6e Merge remote-tracking branch 'origin/staging' into fix/character-tracker-root-envelope-7208

📊 Changes

5 files changed (+77 additions, -6 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/routes/generate.routes.ts (+6 -1)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+6 -1)
📝 packages/server/src/services/agents/agent-executor.ts (+12 -4)
📝 scripts/regressions/agent-runtime.regression.ts (+52 -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 #7208

Thanks to @bahaynes for the diagnosis: the report pinned the exact branch in parseAgentResponse, the debug-only log line and the share of affected runs (91 of 1,278 Character Tracker runs, up to 31 of 68 in one chat).

Why this change

  • When the Character Tracker model returns its incremental update as { "updates": [...], "removed": [...] } at the root of the result instead of under presentCharacters, Engine threw the whole update away. The run still counted as a success, so nothing reached the user: the tracker panel kept the old moods, outfits and thoughts, and the next turn fed that stale snapshot back to the model, which tends to undo recent changes.
  • Custom Tracker already accepts this root shape. Character Tracker is the only other tracker result with a single row group, so the same tolerance applies to it without any ambiguity.
  • The only trace was a debug line, so the loss was invisible at the default log level.

What changed

  • packages/server/src/services/agents/agent-executor.ts: parseAgentResponse now maps both single-group tracker results to the key a root envelope belongs under (custom_tracker_update → fields, character_tracker_update → presentCharacters) and wraps a root { updates, removed } (or { updates } alone) there. Existing shapes are unchanged: an explicit presentCharacters (array or envelope) is never overridden. Both the individual and the batched paths go through this function.
  • packages/server/src/routes/generate.routes.ts and packages/server/src/routes/generate/retry-agents-route.ts: when a successful Character Tracker result has other data but no usable character list (missing or malformed), the "keeping existing snapshot" line is now a warn and names the result's keys. Two replies stay at debug as before: an empty {}, which the package prompt asks for when nothing changed in incremental mode, and an explicitly empty presentCharacters: [], which the guard keeps from wiping the tracker. Warning on those would fire on every quiet turn.
  • scripts/regressions/agent-runtime.regression.ts: feeds the reporter's redacted shape through executeAgent and executeAgentBatch (batched with World State), then through the Character Tracker merge (resolveTrackerGroupUpdate), for root { updates, removed }, root { updates }, presentCharacters: { updates, removed } and the legacy presentCharacters: [...] array. It asserts the snapshot changes in every case. It fails on current staging at the root { updates, removed } case.
  • CHANGELOG.md: user-facing entry under [Unreleased].

Other tracker result types checked for the same gap, not changed because a root envelope would be ambiguous there and they take a different code path:

  • World State (game_state_update): several fields per result; only worldCustomFields takes an envelope.
  • Inventory Tracker (inventory_tracker_update): three row groups (currencies, equipped, inventory).
  • Persona Stats (persona_stats_update): takes arrays only (stats, status), no incremental envelope.

Package side (Pasta-Devs/Marinara-Agents, not changed here): as the report notes, the Character Tracker's batch and incremental hints never show the envelope's parent key. Showing "presentCharacters": { "updates": [...], "removed": [...] } explicitly in the package prompt would make the root shape rarer; Engine now accepts both either way.

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

Agent-run commands: pnpm check (exit 0) and node ./scripts/run-regressions.mjs --filter scripts/regressions/agent-runtime.regression.ts (passes; fails with the executor change reverted). Verifier: same regression passes on the branch and fails with agent-executor.ts taken from origin/staging; tracker-sections, roleplay-streaming, agent-context-generation and prompt regressions pass; pnpm check rerun after the log-level follow-up.

Manual verification notes

  • Manually verify in a Roleplay chat with Character Tracker enabled (alone, and batched with World State) that a turn where the model returns { "updates": [...], "removed": [...] } at the root updates the tracker panel's mood, outfit and thoughts.
  • Manually verify that a turn returning presentCharacters as an array or as { "updates": [...], "removed": [...] } still updates the panel as before.
  • Manually verify that Retry agents on such a message applies the root-shaped update too.
  • Manually verify that a Character Tracker reply with no character list (for example { "reasoning": "..." }) leaves the panel unchanged and logs a warn line naming the result keys at the default log level, while a {} reply and presentCharacters: [] stay quiet at the default log level.
  • Manually verify that locked character fields still keep their values when the update arrives in the root shape.

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)

Only CHANGELOG.md changed; no user-facing docs under docs/ describe the tracker result shapes.

UI evidence (if applicable)

Server-side only; no UI changes.

Summary by CodeRabbit

  • Bug Fixes
    • Character Tracker now processes incremental updates provided at the response root or under presentCharacters. Existing character details are preserved when updates omit characters, while explicit removals are applied.
    • Replies containing other data but no usable character list now generate a server warning that includes the available result keys. Empty “no changes” replies remain quiet or are logged at debug level.
    • Tracked mood, outfit, and thought values no longer remain stale after character changes without a presentCharacters wrapper.

🔄 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/7222 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/character-tracker-root-envelope-7208` --- ### 📝 Commits (3) - [`41b555e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/41b555eff52ef52210e9f9c1ce1ab65ec45b028b) fix(agents): keep Character Tracker updates returned at the result root - [`f82dbc7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f82dbc78fd430522ea484d6766c6c2321dd3cadb) fix(agents): keep Character Tracker no-change replies at debug level - [`a223d6e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a223d6e2ef89c3a889cfa94aa7e9d15d5e02fef8) Merge remote-tracking branch 'origin/staging' into fix/character-tracker-root-envelope-7208 ### 📊 Changes **5 files changed** (+77 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+6 -1) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+6 -1) 📝 `packages/server/src/services/agents/agent-executor.ts` (+12 -4) 📝 `scripts/regressions/agent-runtime.regression.ts` (+52 -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`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7208 Thanks to @bahaynes for the diagnosis: the report pinned the exact branch in `parseAgentResponse`, the debug-only log line and the share of affected runs (91 of 1,278 Character Tracker runs, up to 31 of 68 in one chat). ## Why this change - When the Character Tracker model returns its incremental update as `{ "updates": [...], "removed": [...] }` at the root of the result instead of under `presentCharacters`, Engine threw the whole update away. The run still counted as a success, so nothing reached the user: the tracker panel kept the old moods, outfits and thoughts, and the next turn fed that stale snapshot back to the model, which tends to undo recent changes. - Custom Tracker already accepts this root shape. Character Tracker is the only other tracker result with a single row group, so the same tolerance applies to it without any ambiguity. - The only trace was a `debug` line, so the loss was invisible at the default log level. ## What changed - `packages/server/src/services/agents/agent-executor.ts`: `parseAgentResponse` now maps both single-group tracker results to the key a root envelope belongs under (`custom_tracker_update` → `fields`, `character_tracker_update` → `presentCharacters`) and wraps a root `{ updates, removed }` (or `{ updates }` alone) there. Existing shapes are unchanged: an explicit `presentCharacters` (array or envelope) is never overridden. Both the individual and the batched paths go through this function. - `packages/server/src/routes/generate.routes.ts` and `packages/server/src/routes/generate/retry-agents-route.ts`: when a successful Character Tracker result has other data but no usable character list (missing or malformed), the "keeping existing snapshot" line is now a `warn` and names the result's keys. Two replies stay at `debug` as before: an empty `{}`, which the package prompt asks for when nothing changed in incremental mode, and an explicitly empty `presentCharacters: []`, which the guard keeps from wiping the tracker. Warning on those would fire on every quiet turn. - `scripts/regressions/agent-runtime.regression.ts`: feeds the reporter's redacted shape through `executeAgent` and `executeAgentBatch` (batched with World State), then through the Character Tracker merge (`resolveTrackerGroupUpdate`), for root `{ updates, removed }`, root `{ updates }`, `presentCharacters: { updates, removed }` and the legacy `presentCharacters: [...]` array. It asserts the snapshot changes in every case. It fails on current `staging` at the root `{ updates, removed }` case. - `CHANGELOG.md`: user-facing entry under `[Unreleased]`. Other tracker result types checked for the same gap, not changed because a root envelope would be ambiguous there and they take a different code path: - World State (`game_state_update`): several fields per result; only `worldCustomFields` takes an envelope. - Inventory Tracker (`inventory_tracker_update`): three row groups (`currencies`, `equipped`, `inventory`). - Persona Stats (`persona_stats_update`): takes arrays only (`stats`, `status`), no incremental envelope. Package side (Pasta-Devs/Marinara-Agents, not changed here): as the report notes, the Character Tracker's batch and incremental hints never show the envelope's parent key. Showing `"presentCharacters": { "updates": [...], "removed": [...] }` explicitly in the package prompt would make the root shape rarer; Engine now accepts both either way. ## 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` Agent-run commands: `pnpm check` (exit 0) and `node ./scripts/run-regressions.mjs --filter scripts/regressions/agent-runtime.regression.ts` (passes; fails with the executor change reverted). Verifier: same regression passes on the branch and fails with `agent-executor.ts` taken from `origin/staging`; `tracker-sections`, `roleplay-streaming`, `agent-context-generation` and `prompt` regressions pass; `pnpm check` rerun after the log-level follow-up. ### Manual verification notes - Manually verify in a Roleplay chat with Character Tracker enabled (alone, and batched with World State) that a turn where the model returns `{ "updates": [...], "removed": [...] }` at the root updates the tracker panel's mood, outfit and thoughts. - Manually verify that a turn returning `presentCharacters` as an array or as `{ "updates": [...], "removed": [...] }` still updates the panel as before. - Manually verify that **Retry agents** on such a message applies the root-shaped update too. - Manually verify that a Character Tracker reply with no character list (for example `{ "reasoning": "..." }`) leaves the panel unchanged and logs a `warn` line naming the result keys at the default log level, while a `{}` reply and `presentCharacters: []` stay quiet at the default log level. - Manually verify that locked character fields still keep their values when the update arrives in the root shape. ## 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) Only `CHANGELOG.md` changed; no user-facing docs under `docs/` describe the tracker result shapes. ## UI evidence (if applicable) Server-side only; no UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Character Tracker now processes incremental updates provided at the response root or under `presentCharacters`. Existing character details are preserved when updates omit characters, while explicit removals are applied. * Replies containing other data but no usable character list now generate a server warning that includes the available result keys. Empty “no changes” replies remain quiet or are logged at debug level. * Tracked mood, outfit, and thought values no longer remain stale after character changes without a `presentCharacters` wrapper. <!-- 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-24 04:06:01 +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#7630
No description provided.