mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2723] [Issue]: Committed tracker-context injection is lossy and divergent — active quests, objective progress, and dry-run preview drop or misrepresent state #1367
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1367
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2723
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The committed-context block (
injectCommittedTrackerContext) is what tells the model on the NEXT turn what the established tracker state is. It is the sole live tracker-context renderer (the richerexpandWorldStateAgentis dead code), and it is lossy: it silently drops active quests whose objectives are all done, hard-codes every objective as an empty[ ]checkbox hiding all progress, and emits[object Object]/undefined/undefinedfor malformed rows. Worse, the prompt-preview / dry-run path renders tracker context with a completely DIFFERENT, ungated, non-lossy renderer, so a user debugging "why is the model ignoring my trackers" sees a preview that does not match what is actually sent. The net effect is the classic "tracker panel shows it, model forgets/re-narrates it" complaint.Bug 1 — Active quest with all objectives complete is dropped from context (high)
How it breaks the pipeline:
compactQuestProgressForContextremoves any quest whose objectives are all complete even whenquest.completed===false, so the quest is excluded from the injected Active Quests block while the panel still renders it as a normal open quest. The model is never told the quest exists and forgets/duplicates it.Steps to replicate: Create/advance an active quest; tick every objective complete but do NOT mark the quest completed. Panel shows it at 100% / N/N; next turn the model has no knowledge of it.
Code trace:
quest-state.ts:220-235—:222if(quest.completed) return [];:224filter incomplete;:225if(quest.objectives.length>0 && objectives.length===0) return []drops the active-but-all-done quest. Consumed atcommitted-tracker-context.ts:105-116. RendererQuestRow.tsx:60-63,99,152still shows it active. Sibling injectorschats.routes.ts:298-305andgame.routes.ts:2843-2855keep this exact state visible, confirming the inconsistency.Bug 2 — Objective progress hidden: completed objectives stripped, survivors hard-coded '[ ]' (medium)
How it breaks the pipeline: The renderer prints every surviving objective as
[ ] ${objective.text}with a literal empty checkbox andobjective.completedis never read; combined with the compactor stripping completed objectives, a quest[done, done, pending]reaches the prompt as just[ ] pending, so the model re-narrates finished steps.Steps to replicate: Quest with two completed and one pending objective; inspect the injected context — it shows only the pending objective with an empty checkbox, no signal of the two done.
Code trace:
committed-tracker-context.ts:107-110literal[ ];quest-state.ts:224filters completed objectives. The data exists (game-state.ts:133{text;completed}). Deadmarker-expander.ts:573-576rendered[x]/[ ]correctly but is unreachable (Bug 3).Bug 3 — Only live tracker-context renderer is the lossy one; richer renderer is dead code (medium)
How it breaks the pipeline:
expandAgentDataearly-returns{content:''}for anyagentTypeinAUTO_INJECTED_TRACKERS(incl. 'world-state') before theexpandWorldStateAgentbranch can run, so the richer renderer (full[x]/[ ],(completed)quests, uncommitted-snapshot fallback) never reaches the prompt — masking Bugs 1-2 and confusing maintainers who patch the wrong function.Code trace:
marker-expander.ts:448-455AUTO_INJECTED_TRACKERSset + early return;:463-468unreachableworld-statebranch;:494-599deadexpandWorldStateAgent. Live path:injectCommittedTrackerContextimportedgenerate.routes.ts:356, called:4528.Bug 4 — Present character with missing name injected as '[object Object]' (low)
How it breaks the pipeline: For an object entry lacking
name, the renderer interpolates the object itself, stringifying to[object Object], polluting the model's view of who is present.Steps to replicate: Have the character-tracker emit (or manually store) a present-character object with no
namefield; inspect the injected context line.Code trace:
committed-tracker-context.ts:84`- ${character.emoji ?? ''} ${character.name ?? character}${detailStr}`;character.name ?? characteryields the object.PresentCharacter.namedeclared required (game-state.ts:48-49) but unenforced at runtime (tool passthrough,chats.routes.ts:1481). Sibling code already filters nameless entries (game-gm-prompt-runtime.ts:251-252). Also a leading double space when emoji is absent.Bug 5 — Stat values render 'undefined/undefined' into the prompt (low)
How it breaks the pipeline: Bar/stat value/max are interpolated with no finite-number guard, so a partial tracker write (
{name:'Hunger'}with no value/max) injects- Hunger: undefined/undefined, degrading the model's grounding.Code trace:
committed-tracker-context.ts:93`- ${bar.name}: ${bar.value}/${bar.max}`(unconditional);:127${stat.value}${stat.max ? '/'+stat.max : ''}(value unguarded). NoNumber.isFiniteanywhere in the file; agent output uncoerced upstream (generate-route-utils.ts:136stores verbatim). (Note: literal JSNaNis not reachable via JSON.parse; onlyundefined/string values occur.)Bug 6 — Dry-run / prompt-preview uses different, ungated, non-lossy tracker rendering (medium)
How it breaks the pipeline: The dry-run route reimplements its own
formatTrackersContextBlockthat does NO active-agent gating and renders quests with real[x]/(completed), so the preview shows tracker sections and completed-objective state the real prompt never contains — directly misleading users debugging tracker issues.Steps to replicate: With only world-state active, open prompt preview / extension dry-run; it shows Persona Stats / Inventory / Quests sections and completed-objective checkboxes that real generation gates out / strips.
Code trace:
dry-run-route.ts:129-232(nohasCharTracker/...gating; quests at:185-192keep completed and use[x]/[ ]); callers:1113-1119,:1411-1414gate only on the request flag. Live pathcommitted-tracker-context.ts:45-134gates each section and runscompactQuestProgressForContext. Both load the identical snapshot viagetForGeneration. Route comments (dry-run-route.ts:722,:1567) state the preview must mirror real generation.Suggested Fix
compactQuestProgressForContext, only drop a quest whenquest.completed===true; keep active-but-all-objectives-done quests (optionally with a 'ready to turn in' marker). (Bug 1.)[x]/[ ]fromobjective.completed(or at minimum a(done X/Y)summary) instead of stripping completed objectives and hard-coding[ ]. (Bug 2.)expandWorldStateAgentand the unreachable branch (or remove 'world-state' fromAUTO_INJECTED_TRACKERSif it is the intended renderer) to keep one source of truth. (Bug 3.)nameis missing and join non-empty[emoji, name]parts. (Bug 4.)value/maxto finite numbers before rendering; skip or substitute when not finite. (Bug 5.)injectCommittedTrackerContextwith the chat's real active-agent set so preview is byte-identical to generation. (Bug 6.)Template checklist
pnpm checkpasses (TypeScript + ESLint)[x](or a done X/Y summary) in the injected contextexpandWorldStateAgentremoval/rewire does not regress any marker expansion[object Object]undefined/undefinedAffected files
packages/shared/src/utils/quest-state.tspackages/server/src/services/generation/committed-tracker-context.tspackages/server/src/services/prompt/marker-expander.tspackages/server/src/routes/generate/dry-run-route.tspackages/server/src/routes/generate.routes.tsAudit provenance
Found by a multi-agent static audit of the trackers/widgets subsystem (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). Severity: HIGH. Line numbers are against the
stagingworking tree.@kolacheee commented on GitHub (Jun 21, 2026):
Scope/fix correction for Bug 6 — the dry-run route is NOT the only divergent preview renderer, and there is a second uncited offender.
formatPeekTrackerContextBlockinpackages/server/src/routes/chats.routes.ts(defined L226-347, invoked at L2072 for thePOST /:id/peek-promptroute at L1565, whose responsesourceis"live_preview"at L2087) is a second tracker-context preview renderer with the same intended-mirror-but-divergent contract: its caller comment at L2061 says it must "mirror the read-only snapshot injection from /api/generate."How it diverges from the real generation path (
injectCommittedTrackerContext):stats.activeQuestsdirectly with NOcompactQuestProgressForContext(L298), so it keeps active-but-all-objectives-done quests (Bug 1) and rendersq.completed ? " (completed)"(L303) plus real[x]/[ ]objective state (L301) that generation strips/hides (Bug 2).- ${c.emoji ?? ""} ${c.name ?? c}at L270 →[object Object]for a nameless present character).- ${b.name}: ${b.value}/${b.max}at L283, and${s.value}at L317 — no finite-number guard).Note one distinction from dry-run: peek IS gated by active agents (L234-240, and the caller guards on
chatEnableAgents/activeAgentIdsat L2069), whereas dry-run'sformatTrackersContextBlockis UNGATED — so they are not identical. dry-run diverges on BOTH gating and lossiness; peek diverges only on lossiness + the malformed-row bugs.Consequence for the suggested fix: the framing "
injectCommittedTrackerContext… is the sole live tracker-context renderer" and Fix #6 ("Delete the dry-run copy and call the sharedinjectCommittedTrackerContext") are incomplete. Deleting only the dry-run copy leaves peek-prompt divergent, so the reported "preview doesn't match what is actually sent" symptom persists for the peek path.Revised Fix #6: route BOTH preview renderers — dry-run
formatTrackersContextBlockAND chatsformatPeekTrackerContextBlock— through the sharedinjectCommittedTrackerContext(or a shared block-builder extracted from it) so all three paths share one lossy-or-corrected implementation. When implementing Fixes 1+2 (stop dropping active-but-all-done quests; render real[x]/[ ]), make the deadexpandWorldStateAgentand both preview copies converge on the corrected renderer instead of being patched separately.Add to Affected files:
packages/server/src/routes/chats.routes.ts.Add a test-plan item (leave unchecked): "Manually verify
POST /:id/peek-prompttracker output matches the real generated prompt for a world-state+quest chat that has an active quest with all objectives complete (it must appear, identically, in both)."Non-blocking note:
compactQuestProgressForContextalso has live consumers atagent-executor.ts:158and:1353(viacompactQuestPlayerStatsForContext); fixing Bug 1 in the shared util — as already proposed — correctly covers them.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in
2d238ae2. Active-but-open quests now stay in committed context with their full objective list, objectives render real [x]/[ ] state, malformed character/stat rows are guarded against [object Object] and undefined/undefined output, dry-run and peek-prompt now route through the shared committed tracker context renderer with real active-agent gating, and the unreachable world-state marker renderer was removed.