[PR #8717] [MERGED] fix(agents): apply or retry ungrouped Inventory Tracker results #8761

Closed
opened 2026-11-07 17:39:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8717
Author: @SpicyMarinara
Created: 11/3/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/inventory-tracker-bare-envelope


📝 Commits (3)

  • 9362654 fix(agents): apply or retry ungrouped Inventory Tracker results
  • 5fe67d9 fix(agents): drop root inventory removals that no group tracks
  • eba6d70 Merge branch 'staging' into fix/inventory-tracker-bare-envelope

📊 Changes

2 files changed (+179 additions, -18 deletions)

View changed files

📝 packages/server/src/services/agents/agent-executor.ts (+103 -18)
📝 scripts/regressions/agent-runtime.regression.ts (+76 -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 #8714 (the Engine half of Pasta-Devs/Marinara-Agents#2077; the package prompt is fixed in Pasta-Devs/Marinara-Agents#2084)

Why this change

The Inventory Tracker agent often returns a bare root envelope, {"updates":[...],"removed":[...]}, with no group. buildLockedInventoryTrackerPatch reads only currencies, equipped and inventory, so it applied nothing, logged nothing, and recorded the run as a success. The executor tolerated a bare envelope only for single-group trackers. In the reporter's chat, 30 of 54 runs lost real purchases, drops and removals this way.

What changed

packages/server/src/services/agents/agent-executor.ts:

  • A root envelope on the Inventory tracker is validated like a group. Each bare row goes to the one group that already tracks that name, using the game state the agent was shown.
  • A mixed response (group parts plus a stray bare part) applies both.
  • A bare removed name that no group tracks is dropped with a log line, since it is a no-op everywhere. A removal tracked by more than one group is ambiguous.
  • If any bare update can't be placed (a new name that could be a currency or an item, or a name in two groups), the whole result is treated as invalid. It is retried like invalid JSON, and if the retry fails too, the run fails with a clear reason.
    • All or nothing: applying only the placed rows would bring the silent drop back.
    • A logger.warn is written either way.
  • An empty bare envelope stays a successful no-change.
  • Single-group trackers are unchanged.

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

What the agent ran:

  • pnpm check passes (exit 0).
  • scripts/regressions/agent-runtime.regression.ts gained cases for a bare currency update, a bare removal, a mixed response, an unplaceable bare row (retried, then failed rather than a successful no-change) and a bare removal of an untracked name (dropped, so the placed update still applies). It fails on staging and passes with the change.
  • Related regressions pass: multiplayer-generation-policy, agent-previous-output, agent-connection-parameters, agent-scene-check, merged-rewrite-lorebooks, capability-agent-runtime, roleplay-streaming, agent-progress, logging-failure-lines, manual-agent-retry-resolution, world-state-time-macros.
  • CodeRabbit: 0 findings on the first commit.
  • An independent review confirmed one finding: a bare removal of an untracked name failed the whole result. It is fixed, and a second pass verified the fix.

Manual verification notes

  • Manually verify with the Inventory Tracker on a small, fast model: purchases, drops and pickups over several turns all show up in the tracker.
  • Manually verify that if the agent sends an update for a brand-new item without a group, the run is retried and, if it still can't be placed, shows as failed rather than silently succeeding.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) 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)

🤖 Generated with Claude Code


🔄 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/8717 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/3/2026 **Status:** ✅ Merged **Merged:** 11/3/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/inventory-tracker-bare-envelope` --- ### 📝 Commits (3) - [`9362654`](https://github.com/Pasta-Devs/Marinara-Engine/commit/93626542f430f44675add76b1549fa903eedab67) fix(agents): apply or retry ungrouped Inventory Tracker results - [`5fe67d9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5fe67d9ee72c69ce0c7bdf66a62e688495033b07) fix(agents): drop root inventory removals that no group tracks - [`eba6d70`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eba6d703889a13261a9f7546e3397b7c72fe56f4) Merge branch 'staging' into fix/inventory-tracker-bare-envelope ### 📊 Changes **2 files changed** (+179 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/agents/agent-executor.ts` (+103 -18) 📝 `scripts/regressions/agent-runtime.regression.ts` (+76 -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 #8714 (the Engine half of Pasta-Devs/Marinara-Agents#2077; the package prompt is fixed in Pasta-Devs/Marinara-Agents#2084) ## Why this change The Inventory Tracker agent often returns a bare root envelope, `{"updates":[...],"removed":[...]}`, with no group. `buildLockedInventoryTrackerPatch` reads only `currencies`, `equipped` and `inventory`, so it applied nothing, logged nothing, and recorded the run as a success. The executor tolerated a bare envelope only for single-group trackers. In the reporter's chat, 30 of 54 runs lost real purchases, drops and removals this way. ## What changed `packages/server/src/services/agents/agent-executor.ts`: - A root envelope on the Inventory tracker is validated like a group. Each bare row goes to the one group that already tracks that name, using the game state the agent was shown. - A mixed response (group parts plus a stray bare part) applies both. - A bare `removed` name that no group tracks is dropped with a log line, since it is a no-op everywhere. A removal tracked by more than one group is ambiguous. - If any bare update can't be placed (a new name that could be a currency or an item, or a name in two groups), the whole result is treated as invalid. It is retried like invalid JSON, and if the retry fails too, the run fails with a clear reason. - All or nothing: applying only the placed rows would bring the silent drop back. - A `logger.warn` is written either way. - An empty bare envelope stays a successful no-change. - Single-group trackers are unchanged. ## 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` What the agent ran: - `pnpm check` passes (exit 0). - `scripts/regressions/agent-runtime.regression.ts` gained cases for a bare currency update, a bare removal, a mixed response, an unplaceable bare row (retried, then failed rather than a successful no-change) and a bare removal of an untracked name (dropped, so the placed update still applies). It fails on `staging` and passes with the change. - Related regressions pass: multiplayer-generation-policy, agent-previous-output, agent-connection-parameters, agent-scene-check, merged-rewrite-lorebooks, capability-agent-runtime, roleplay-streaming, agent-progress, logging-failure-lines, manual-agent-retry-resolution, world-state-time-macros. - CodeRabbit: 0 findings on the first commit. - An independent review confirmed one finding: a bare removal of an untracked name failed the whole result. It is fixed, and a second pass verified the fix. ### Manual verification notes - Manually verify with the Inventory Tracker on a small, fast model: purchases, drops and pickups over several turns all show up in the tracker. - Manually verify that if the agent sends an update for a brand-new item without a group, the run is retried and, if it still can't be placed, shows as failed rather than silently succeeding. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) 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) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:31 +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#8761
No description provided.