[PR #5676] [MERGED] fix(agents): recover the removal a compound take-off loses #6877

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5676
Author: @GetBeholder
Created: 8/30/2026
Status: ✅ Merged
Merged: 8/30/2026
Merged by: @GetBeholder

Base: staging ← Head: fix/beholder-compound-takeoff


📝 Commits (5)

  • 4a1abac fix(agents): recover the removal a compound take-off loses
  • 5902222 Merge remote-tracking branch 'origin/staging' into fix/beholder-compound-takeoff
  • 5eba638 fix(agents): take the repair subject from the take-off's own sentence
  • 73557cd Merge branch 'staging' into fix/beholder-compound-takeoff
  • bc1469b Merge branch 'staging' into fix/beholder-compound-takeoff

📊 Changes

3 files changed (+247 additions, -2 deletions)

View changed files

📝 packages/server/src/services/agents/agent-executor.ts (+67 -2)
📝 packages/server/src/services/agents/beholder-state.ts (+77 -0)
➕ scripts/regressions/beholder-takeoff-repair.regression.ts (+103 -0)

📄 Description

Pull request

Linked issue

Closes #

Why this change

When one sentence both takes a garment off and puts another on, the extractor reports the addition and drops the removal. Measured against the held-out set:

prose removal emitted
take-off alone — "hangs the cloak on a hook" 3/3
compound — "hangs the cloak on a hook and pulls on black boots" 2/8

The garment it failed to remove stays in state and is fed back into every later turn, so one miss compounds for the rest of the scene. This reproduces on ordinary prose, not just constructed cases — a six-turn scene hit it on "trades the ruined sweater for a clean linen shirt… and pulls the coat back on".

What changed

  • beholder-state.ts gains three pure helpers: beholderTakeoffClause (split a compound sentence down to the take-off half), beholderDeltaLacksRemoval, and mergeBeholderWornRemovals.
  • agent-executor.ts runs one extra worn-lane call after the five passes only when the reply carried no removal, the prose shows something coming off, and the sentence is compound. Only worn_remove is merged from the answer — it never adds or replaces a garment. A failed repair is logged and dropped rather than losing the turn.
  • buildBeholderMessages takes an optional narration override; the narration derivation moved to beholderNarration so both callers share it.

The route matters. Re-asking the same compound sentence with removal-only framing recovers 0 of 6 — it is the compound sentence itself that blinds the model, not the framing. That is why this splits the input rather than rewording the prompt. Five prompt variants were measured first (an explicit rule, a worked example, clause-splitting instructions, a terse imperative, and reordering the existing bullet); every one left the number at 2/8.

Package and security impact

  • Affected package IDs: beholder (agent behaviour only; no manifest or catalog change)
  • Engine compatibility impact: none — no schema, route or contract change
  • New or changed permissions/entrypoints: none
  • Restart, storage, update, or uninstall impact: none. Cost is one extra provider call on turns that show a garment coming off and reported no removal; ordinary turns are unaffected.

Validation

  • scripts/regressions/beholder-takeoff-repair.regression.ts passes
  • All pre-existing beholder-* regressions still pass
  • tsc --noEmit -p packages/server/tsconfig.json clean
  • Installed or updated the affected package through Marinara Engine
  • Checked supported modes, restart behavior, and uninstall cleanup

Manual verification notes

Measured end to end through these helpers against the trained extractor (koboldcpp, Beholder-Q8_0):

group before after extra calls
compound 2/8 8/8 5
removal only 3/3 3/3 0
addition only 4/4 4/4 0

The two unticked boxes are honest: this is server-side behaviour with no package payload, so there is nothing to install, and it was verified through the regression harness and a live-model run rather than a chat session.

The unit regression pins what decides when it fires and what it asks — firing too eagerly costs a call on every turn, not firing costs the removal — plus that the merge takes only worn_remove and never duplicates.

Documentation impact

  • No documentation changes needed

UI evidence (if applicable)

None — no UI change.

Summary by CodeRabbit

  • Bug Fixes

    • Improved clothing removal detection for compound narration.
    • Corrected cases where worn-item removals were missed during scene updates.
    • Prevented duplicate removals and unrelated item changes from being applied.
    • Improved handling of take-off actions spanning multiple clauses or sentences.
  • Tests

    • Added regression coverage for compound take-off actions, subject preservation, no-op scenarios, and repaired removal results.

🔄 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/5676 **Author:** [@GetBeholder](https://github.com/GetBeholder) **Created:** 8/30/2026 **Status:** ✅ Merged **Merged:** 8/30/2026 **Merged by:** [@GetBeholder](https://github.com/GetBeholder) **Base:** `staging` ← **Head:** `fix/beholder-compound-takeoff` --- ### 📝 Commits (5) - [`4a1abac`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4a1abacf758547fb6252adf04d9c7331e96dd699) fix(agents): recover the removal a compound take-off loses - [`5902222`](https://github.com/Pasta-Devs/Marinara-Engine/commit/59022223b4e356fb5609711c06af3fcc11d6ff09) Merge remote-tracking branch 'origin/staging' into fix/beholder-compound-takeoff - [`5eba638`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5eba638486ebbabe63bf2b11f3d45fb0f1fc148f) fix(agents): take the repair subject from the take-off's own sentence - [`73557cd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/73557cd3294eb461248bfd820f313b37fad285c3) Merge branch 'staging' into fix/beholder-compound-takeoff - [`bc1469b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bc1469bcb951795d6e5898b6f16011994bdf0d1a) Merge branch 'staging' into fix/beholder-compound-takeoff ### 📊 Changes **3 files changed** (+247 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/agents/agent-executor.ts` (+67 -2) 📝 `packages/server/src/services/agents/beholder-state.ts` (+77 -0) ➕ `scripts/regressions/beholder-takeoff-repair.regression.ts` (+103 -0) </details> ### 📄 Description # Pull request ## Linked issue Closes # ## Why this change When one sentence both takes a garment off and puts another on, the extractor reports the addition and drops the removal. Measured against the held-out set: | prose | removal emitted | |---|---| | take-off alone — *"hangs the cloak on a hook"* | **3/3** | | compound — *"hangs the cloak on a hook **and** pulls on black boots"* | **2/8** | The garment it failed to remove stays in state and is fed back into every later turn, so one miss compounds for the rest of the scene. This reproduces on ordinary prose, not just constructed cases — a six-turn scene hit it on *"trades the ruined sweater for a clean linen shirt… and pulls the coat back on"*. ## What changed - `beholder-state.ts` gains three pure helpers: `beholderTakeoffClause` (split a compound sentence down to the take-off half), `beholderDeltaLacksRemoval`, and `mergeBeholderWornRemovals`. - `agent-executor.ts` runs one extra worn-lane call after the five passes **only** when the reply carried no removal, the prose shows something coming off, and the sentence is compound. Only `worn_remove` is merged from the answer — it never adds or replaces a garment. A failed repair is logged and dropped rather than losing the turn. - `buildBeholderMessages` takes an optional narration override; the narration derivation moved to `beholderNarration` so both callers share it. **The route matters.** Re-asking the *same compound sentence* with removal-only framing recovers **0 of 6** — it is the compound sentence itself that blinds the model, not the framing. That is why this splits the input rather than rewording the prompt. Five prompt variants were measured first (an explicit rule, a worked example, clause-splitting instructions, a terse imperative, and reordering the existing bullet); every one left the number at 2/8. ## Package and security impact - Affected package IDs: `beholder` (agent behaviour only; no manifest or catalog change) - Engine compatibility impact: none — no schema, route or contract change - New or changed permissions/entrypoints: none - Restart, storage, update, or uninstall impact: none. Cost is one extra provider call on turns that show a garment coming off and reported no removal; ordinary turns are unaffected. ## Validation - [x] `scripts/regressions/beholder-takeoff-repair.regression.ts` passes - [x] All pre-existing `beholder-*` regressions still pass - [x] `tsc --noEmit -p packages/server/tsconfig.json` clean - [ ] Installed or updated the affected package through Marinara Engine - [ ] Checked supported modes, restart behavior, and uninstall cleanup ### Manual verification notes Measured end to end through these helpers against the trained extractor (koboldcpp, Beholder-Q8_0): | group | before | after | extra calls | |---|---|---|---| | compound | 2/8 | **8/8** | 5 | | removal only | 3/3 | 3/3 | 0 | | addition only | 4/4 | 4/4 | 0 | The two unticked boxes are honest: this is server-side behaviour with no package payload, so there is nothing to install, and it was verified through the regression harness and a live-model run rather than a chat session. The unit regression pins what decides *when* it fires and *what* it asks — firing too eagerly costs a call on every turn, not firing costs the removal — plus that the merge takes only `worn_remove` and never duplicates. ## Documentation impact - [x] No documentation changes needed ## UI evidence (if applicable) None — no UI change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved clothing removal detection for compound narration. * Corrected cases where worn-item removals were missed during scene updates. * Prevented duplicate removals and unrelated item changes from being applied. * Improved handling of take-off actions spanning multiple clauses or sentences. * **Tests** * Added regression coverage for compound take-off actions, subject preservation, no-op scenarios, and repaired removal results. <!-- 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:14: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#6877
No description provided.