[GH-ISSUE #2491] 13-AGENT-RUNTIME-context-injection-cache: regeneration ignores cached prompt injections #1234

Closed
opened 2026-10-21 05:29:32 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2491

Originally assigned to: @Promansis on GitHub.

Summary

13-AGENT-RUNTIME-context-injection-cache: on regeneration, refactor does not reuse the target assistant message's cached message.extra.contextInjections. It reruns pre-generation agents instead, so edited cached injections can be ignored or overwritten.

Linked tracker: #2482.

Expected behavior

Legacy main reuses cached prompt injections from the target assistant message during regeneration, filters out secret-plot-driver, emits cached injection results, and preserves Knowledge Retrieval / Knowledge Router prompt placement.

Actual behavior

Refactor persists fresh runtime.preInjections to message.extra.contextInjections, but normal regeneration does not load those cached injections back into the runtime. generationReplay does not carry cached injections, and createGenerationAgentRuntime reruns pre-generation agents on regeneration unless the caller passes explicit agentInjectionOverrides.

Steps to reproduce

  1. In a roleplay chat, generate an assistant message with pre-generation context injections.
  2. Edit a cached injection in the Agents HUD Injections tab and save it.
  3. Regenerate that same assistant message.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor static trace, Batch 7 parityscan for #2482
  • Run mode: not run; static trace only
  • OS + version: not relevant
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not relevant
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: agent pre-generation runtime

Logs, screenshots, or video

Proof used:

  • Legacy cache contract: upstream/main:packages/server/src/routes/generate.routes.ts:6615 reuses cached injections on regeneration; :6623 normalizes cache; :6625 filters secret-plot-driver; :6691 splits cached placement; :8028 saves contextInjections.
  • Legacy retry sync: upstream/main:packages/server/src/routes/generate/retry-agents-route.ts:1454 keeps target message.extra.contextInjections synced on injectable agent retry.
  • Refactor contract: src/engine/contracts/types/chat.ts:452 defines cached contextInjections.
  • Refactor fresh persistence: src/engine/generation/start-generation.ts:3453 saves runtime.preInjections.
  • Refactor replay path: src/engine/generation/start-generation.ts:1159 loads generationReplay; src/engine/generation/generation-replay.ts:9 replay fields omit cached injections.
  • Refactor regeneration runtime: src/engine/generation/agent-runner.ts:1050 only suppresses Echo Chamber on regeneration; src/engine/generation/agent-runner.ts:1676 runs pre-generation agents.
  • UI no-gap evidence: src/features/modes/roleplay/components/ContextInjectionPanel.tsx:159 saves edits; :179 rerolls; :22 blocks KR/Router reroll.

Regression notes

Legacy main preserves edited cached injections for regeneration. Refactor has the UI and persistence surface, but misses regeneration reuse.

Additional context

Acceptance criteria:

  • Regenerating an assistant message reuses normalized message.extra.contextInjections from that target when present.
  • Reused cache excludes secret-plot-driver.
  • KR/Router cached injections preserve their intended prompt placement / preset-section behavior.
  • Edited cached injections in the Agents HUD survive regeneration unless explicitly rerolled.
  • Fresh generation and explicit review overrides still persist the final used injections to message.extra.contextInjections.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2491 Originally assigned to: @Promansis on GitHub. ## Summary `13-AGENT-RUNTIME-context-injection-cache`: on regeneration, refactor does not reuse the target assistant message's cached `message.extra.contextInjections`. It reruns pre-generation agents instead, so edited cached injections can be ignored or overwritten. Linked tracker: #2482. ## Expected behavior Legacy `main` reuses cached prompt injections from the target assistant message during regeneration, filters out `secret-plot-driver`, emits cached injection results, and preserves Knowledge Retrieval / Knowledge Router prompt placement. ## Actual behavior Refactor persists fresh `runtime.preInjections` to `message.extra.contextInjections`, but normal regeneration does not load those cached injections back into the runtime. `generationReplay` does not carry cached injections, and `createGenerationAgentRuntime` reruns pre-generation agents on regeneration unless the caller passes explicit `agentInjectionOverrides`. ## Steps to reproduce 1. In a roleplay chat, generate an assistant message with pre-generation context injections. 2. Edit a cached injection in the Agents HUD Injections tab and save it. 3. Regenerate that same assistant message. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [x] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [ ] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: `refactor` static trace, Batch 7 parityscan for #2482 - Run mode: not run; static trace only - OS + version: not relevant - Node + pnpm versions: not relevant - Rust version, if relevant: not relevant - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: agent pre-generation runtime ## Logs, screenshots, or video Proof used: - Legacy cache contract: `upstream/main:packages/server/src/routes/generate.routes.ts:6615` reuses cached injections on regeneration; `:6623` normalizes cache; `:6625` filters `secret-plot-driver`; `:6691` splits cached placement; `:8028` saves `contextInjections`. - Legacy retry sync: `upstream/main:packages/server/src/routes/generate/retry-agents-route.ts:1454` keeps target `message.extra.contextInjections` synced on injectable agent retry. - Refactor contract: `src/engine/contracts/types/chat.ts:452` defines cached `contextInjections`. - Refactor fresh persistence: `src/engine/generation/start-generation.ts:3453` saves `runtime.preInjections`. - Refactor replay path: `src/engine/generation/start-generation.ts:1159` loads `generationReplay`; `src/engine/generation/generation-replay.ts:9` replay fields omit cached injections. - Refactor regeneration runtime: `src/engine/generation/agent-runner.ts:1050` only suppresses Echo Chamber on regeneration; `src/engine/generation/agent-runner.ts:1676` runs pre-generation agents. - UI no-gap evidence: `src/features/modes/roleplay/components/ContextInjectionPanel.tsx:159` saves edits; `:179` rerolls; `:22` blocks KR/Router reroll. ## Regression notes Legacy `main` preserves edited cached injections for regeneration. Refactor has the UI and persistence surface, but misses regeneration reuse. ## Additional context Acceptance criteria: - Regenerating an assistant message reuses normalized `message.extra.contextInjections` from that target when present. - Reused cache excludes `secret-plot-driver`. - KR/Router cached injections preserve their intended prompt placement / preset-section behavior. - Edited cached injections in the Agents HUD survive regeneration unless explicitly rerolled. - Fresh generation and explicit review overrides still persist the final used injections to `message.extra.contextInjections`. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:29:32 +07:00
  • closed this issue
  • added the
    bug
    label
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#1234
No description provided.