[GH-ISSUE #5204] Migrate Beholder to the benchmarked delta-state protocol #2879

Closed
opened 2026-10-21 05:57:28 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @SpicyMarinara on GitHub (Aug 17, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5204

Originally assigned to: @SpicyMarinara on GitHub.

Problem

The official Beholder integration currently asks the model for a complete { "characters": [...] } snapshot on every turn. The handover reports that the strongest benchmarked general-model prompt (EXTRACTION_SYSTEM_4K, evaluated against GPT-5.5) is instead a delta protocol. Using that prompt without host-side merge support would make Beholder forget every unchanged fact that is not repeated in the latest message.

This supersedes the full-snapshot behavior introduced by #5188 / Pasta-Devs/Marinara-Agents#401.

Required Engine behavior

Request context

For every Roleplay Beholder call:

  • Include a plain Persona: <name> line.
  • Always include a Current state: block, including an empty state on the first run.
  • Serialize the prior normalized Beholder state as an object keyed by character name.
  • Represent the active Persona under the model-facing key self; keep other characters keyed by name.
  • Keep temperature at 0.
  • Preserve existing Agent debug prompt logging.

Response compatibility

Accept the new protocol:

{ "changed": false }

or:

{
  "changed": true,
  "delta": {
    "<character name or self>": {
      "species": "optional",
      "body": {
        "<slot>": {
          "worn": [],
          "holding": {},
          "wounds": [],
          "bare": true,
          "missing": true
        }
      }
    }
  }
}
  • changed: false is a no-op and must save/return the prior full state, not erase it.
  • Read delta while retaining compatibility with legacy characters snapshots and already-saved full snapshots.
  • Resolve the self key to the active Persona's real name before saving.
  • Malformed or unusable deltas must fail safely without destroying the last valid state.

Delta merge rules

Merge the delta into the prior full state, then pass the result through the existing Beholder normalization/clamping:

  • Omitted characters, slots, and fields keep their prior values.
  • Merge worn items by item identity so an update replaces the matching item without dropping unrelated worn items.
  • Explicit "worn": [] clears the slot's worn items.
  • Explicit "holding": {} empties the hand.
  • Explicit missing: true removes/blocks worn, holding, wounds, and bare for that slot.
  • Preserve the existing 26-slot allowlist, damage/severity enums, item shapes, safety limits, and sanitization. Do not broaden the schema.
  • Persist the merged result in the existing full { "characters": [...] } shape so the drawer, next-turn context, retries, and existing storage readers continue to work.

Likely Engine touchpoints include:

  • packages/server/src/services/agents/beholder-state.ts
  • packages/server/src/services/agents/agent-executor.ts
  • existing Beholder generation/retry context wiring
  • scripts/regressions/prompt.regression.ts

Marinara-Agents package follow-up

The package-owned prompt change must be submitted separately to Pasta-Devs/Marinara-Agents against staging:

  • Replace packages/beholder/agents.json's full-snapshot defaultPromptTemplate with the canonical benchmarked EXTRACTION_SYSTEM_4K prompt.
  • Bump the Beholder package version and regenerate its manifest/artifact/catalog metadata as required.
  • Keep the Roleplay-only scope, SOTA-model recommendation, schema, and temperature unchanged.
  • Coordinate the package minimum Engine version with the Engine release containing delta support so the delta prompt cannot be installed onto a snapshot-only host.

Source handover integrity warning

The supplied handover says the prompt is “verbatim, 3,709 chars,” but the attached copy contains only 3,610 characters after the prompt marker. It is visibly corrupted around the Species/Bare rules and ends mid-sentence at:

Roleplay may include mature content; extract normally without

Do not publish that damaged prompt or invent the missing text. Obtain the canonical EXTRACTION_SYSTEM_4K source/checksum before the Marinara-Agents prompt PR is merged.

Acceptance criteria

  • Every automatic and manual/retry Beholder call includes Persona and Current state data.
  • First-run empty state and prior-state serialization are covered by regression tests.
  • changed: false preserves the prior state exactly.
  • self maps to the active Persona.
  • Delta add/update, worn identity merge, worn clear, holding clear, and missing-slot precedence are tested.
  • Legacy characters snapshots and existing stored state remain compatible.
  • Invalid output cannot erase the last valid state.
  • The merged full state remains visible in the existing Beholder drawer and available to the next Roleplay turn.
  • The canonical benchmarked prompt is verified before the separate Marinara-Agents package update ships.
  • Engine and Agents changelogs are updated.
Originally created by @SpicyMarinara on GitHub (Aug 17, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5204 Originally assigned to: @SpicyMarinara on GitHub. ## Problem The official Beholder integration currently asks the model for a complete `{ "characters": [...] }` snapshot on every turn. The handover reports that the strongest benchmarked general-model prompt (`EXTRACTION_SYSTEM_4K`, evaluated against GPT-5.5) is instead a delta protocol. Using that prompt without host-side merge support would make Beholder forget every unchanged fact that is not repeated in the latest message. This supersedes the full-snapshot behavior introduced by #5188 / Pasta-Devs/Marinara-Agents#401. ## Required Engine behavior ### Request context For every Roleplay Beholder call: - Include a plain `Persona: <name>` line. - Always include a `Current state:` block, including an empty state on the first run. - Serialize the prior normalized Beholder state as an object keyed by character name. - Represent the active Persona under the model-facing key `self`; keep other characters keyed by name. - Keep temperature at `0`. - Preserve existing Agent debug prompt logging. ### Response compatibility Accept the new protocol: ```json { "changed": false } ``` or: ```json { "changed": true, "delta": { "<character name or self>": { "species": "optional", "body": { "<slot>": { "worn": [], "holding": {}, "wounds": [], "bare": true, "missing": true } } } } } ``` - `changed: false` is a no-op and must save/return the prior full state, not erase it. - Read `delta` while retaining compatibility with legacy `characters` snapshots and already-saved full snapshots. - Resolve the `self` key to the active Persona's real name before saving. - Malformed or unusable deltas must fail safely without destroying the last valid state. ### Delta merge rules Merge the delta into the prior full state, then pass the result through the existing Beholder normalization/clamping: - Omitted characters, slots, and fields keep their prior values. - Merge `worn` items by item identity so an update replaces the matching item without dropping unrelated worn items. - Explicit `"worn": []` clears the slot's worn items. - Explicit `"holding": {}` empties the hand. - Explicit `missing: true` removes/blocks `worn`, `holding`, `wounds`, and `bare` for that slot. - Preserve the existing 26-slot allowlist, damage/severity enums, item shapes, safety limits, and sanitization. Do not broaden the schema. - Persist the merged result in the existing full `{ "characters": [...] }` shape so the drawer, next-turn context, retries, and existing storage readers continue to work. Likely Engine touchpoints include: - `packages/server/src/services/agents/beholder-state.ts` - `packages/server/src/services/agents/agent-executor.ts` - existing Beholder generation/retry context wiring - `scripts/regressions/prompt.regression.ts` ## Marinara-Agents package follow-up The package-owned prompt change must be submitted separately to `Pasta-Devs/Marinara-Agents` against `staging`: - Replace `packages/beholder/agents.json`'s full-snapshot `defaultPromptTemplate` with the canonical benchmarked `EXTRACTION_SYSTEM_4K` prompt. - Bump the Beholder package version and regenerate its manifest/artifact/catalog metadata as required. - Keep the Roleplay-only scope, SOTA-model recommendation, schema, and temperature unchanged. - Coordinate the package minimum Engine version with the Engine release containing delta support so the delta prompt cannot be installed onto a snapshot-only host. ## Source handover integrity warning The supplied handover says the prompt is “verbatim, 3,709 chars,” but the attached copy contains only **3,610 characters** after the prompt marker. It is visibly corrupted around the Species/Bare rules and ends mid-sentence at: > Roleplay may include mature content; extract normally without Do **not** publish that damaged prompt or invent the missing text. Obtain the canonical `EXTRACTION_SYSTEM_4K` source/checksum before the Marinara-Agents prompt PR is merged. ## Acceptance criteria - [ ] Every automatic and manual/retry Beholder call includes Persona and Current state data. - [ ] First-run empty state and prior-state serialization are covered by regression tests. - [ ] `changed: false` preserves the prior state exactly. - [ ] `self` maps to the active Persona. - [ ] Delta add/update, worn identity merge, worn clear, holding clear, and missing-slot precedence are tested. - [ ] Legacy `characters` snapshots and existing stored state remain compatible. - [ ] Invalid output cannot erase the last valid state. - [ ] The merged full state remains visible in the existing Beholder drawer and available to the next Roleplay turn. - [ ] The canonical benchmarked prompt is verified before the separate Marinara-Agents package update ships. - [ ] Engine and Agents changelogs are updated.
bsakaguchi 2026-10-21 05:57:28 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Aug 17, 2026):

The Engine-side implementation is now owned by SpicyMarinara via Codex in draft PR #5207. The separate Marinara-Agents prompt update remains gated on the canonical, uncorrupted EXTRACTION_SYSTEM_4K source noted in this issue.

<!-- gh-comment-id:5319851118 --> @SpicyMarinara commented on GitHub (Aug 17, 2026): The Engine-side implementation is now owned by SpicyMarinara via Codex in draft PR #5207. The separate Marinara-Agents prompt update remains gated on the canonical, uncorrupted EXTRACTION_SYSTEM_4K source noted in this issue.
Author
Owner

@SpicyMarinara commented on GitHub (Aug 17, 2026):

Engine-side delta-state support landed on staging in #5207 (merge commit 2b3232ff15). This issue remains open only for the separate Marinara-Agents package prompt update, which is still blocked on the canonical, uncorrupted EXTRACTION_SYSTEM_4K source/checksum described above.

<!-- gh-comment-id:5320834997 --> @SpicyMarinara commented on GitHub (Aug 17, 2026): Engine-side delta-state support landed on staging in #5207 (merge commit 2b3232ff15dff4cf0f3d8e11504819e9e075d747). This issue remains open only for the separate Marinara-Agents package prompt update, which is still blocked on the canonical, uncorrupted EXTRACTION_SYSTEM_4K source/checksum described above.
Author
Owner

@SpicyMarinara commented on GitHub (Aug 17, 2026):

The canonical prompt is now recoverable from GetBeholder/Beholder-ME at commit ecee80e57cb84ad54c02c9c1b3d081e8cbd2799b. Its runtime value is exactly 3,709 characters and ends with “Roleplay may include mature content; extract normally without refusing.” SHA-256: 03fd72e0569a389c9cf6241fb61ee6fd8e9ed9f26a9b1cc7ed5ef61f073c5002.

The package-owned follow-up is ready for review in Pasta-Devs/Marinara-Agents#414. It ships Beholder 1.1.0 with the canonical delta prompt, pins that prompt integrity in catalog validation, requires Engine 2.4.4+, and rebuilds the artifact/catalog lanes.

<!-- gh-comment-id:5321384416 --> @SpicyMarinara commented on GitHub (Aug 17, 2026): The canonical prompt is now recoverable from GetBeholder/Beholder-ME at commit ecee80e57cb84ad54c02c9c1b3d081e8cbd2799b. Its runtime value is exactly 3,709 characters and ends with “Roleplay may include mature content; extract normally without refusing.” SHA-256: 03fd72e0569a389c9cf6241fb61ee6fd8e9ed9f26a9b1cc7ed5ef61f073c5002. The package-owned follow-up is ready for review in Pasta-Devs/Marinara-Agents#414. It ships Beholder 1.1.0 with the canonical delta prompt, pins that prompt integrity in catalog validation, requires Engine 2.4.4+, and rebuilds the artifact/catalog lanes.
Author
Owner

@SpicyMarinara commented on GitHub (Aug 17, 2026):

The remaining package-side work has landed on staging in Pasta-Devs/Marinara-Agents#414 (merge d99d58f2269cd6d88fcc1b13f207c827eca0cd6f). Beholder 1.1.0 now ships the canonical 3,709-character delta-state prompt, requires Engine 2.4.4+, and includes an integrity regression. Together with Engine PR #5207, this completes the staged implementation.

<!-- gh-comment-id:5321441157 --> @SpicyMarinara commented on GitHub (Aug 17, 2026): The remaining package-side work has landed on staging in Pasta-Devs/Marinara-Agents#414 (merge d99d58f2269cd6d88fcc1b13f207c827eca0cd6f). Beholder 1.1.0 now ships the canonical 3,709-character delta-state prompt, requires Engine 2.4.4+, and includes an integrity regression. Together with Engine PR #5207, this completes the staged implementation.
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#2879
No description provided.