mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1191] [MERGED] Strip avatarPath from agent gameState serialization #4968
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#4968
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1191
Author: @Romuromylus
Created: 5/25/2026
Status: ✅ Merged
Merged: 5/25/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/agent-context-avatar-bloat📝 Commits (2)
e3bdae8Strip avatarPath from agent gameState serializationd9be35cExtract stripAvatarPathsReplacer and cover sibling sites📊 Changes
3 files changed (+25 additions, -3 deletions)
View changed files
📝
src/engine/agents-runtime/executor/agent-executor.ts(+3 -2)📝
src/engine/agents-runtime/knowledge/knowledge-router.ts(+2 -1)➕
src/engine/agents-runtime/strip-avatar-paths.ts(+20 -0)📄 Description
Why this change
Imported pre-refactor chats can carry full base64 image data URLs in
gameState.presentCharacters[].avatarPath- the legacy backup format inlines avatars rather than referencing asset paths. Three sites in the agents-runtime layer serializegameState(or a tracker summary built from it) into agent prompts, each of which can pick up a megabyte+ of base64 per present character.On 1M-token providers (e.g. Gemini) the agent prompt blew past the ceiling and every tracker agent failed with:
applyAgentResultEffectsinsrc/features/runtime/generation/hooks/use-generate.tsshort-circuits on!result.success, so the failures never reached the bubble / tracker handlers and the user-visible symptom was both panels stuck on their empty states ("No tracker data yet" and "No agent activity yet") with no error indication, even though the main chat reply itself succeeded.What changed
New named helper
stripAvatarPathsReplaceratsrc/engine/agents-runtime/strip-avatar-paths.ts- aJSON.stringifyreplacer that drops anyavatarPathkey from the serialized tree.avatarPathis a UI display field (image path or data URL the tracker panel renders); the model never reads it. Every other model-relevant field on each present character (name,mood,appearance,outfit,stats,thoughts,customFields, etc.) is preserved as before.The helper is now applied at all three sites that serialize
gameStateor a tracker summary built from it into a prompt:buildAgentExtras<current_game_state>block atsrc/engine/agents-runtime/executor/agent-executor.ts- the original site identified in #1188.buildAgentMessages<committed_tracker_state>block atsrc/engine/agents-runtime/executor/agent-executor.ts- attaches a tracker summary to the last 3 assistant messages and assignsgs.presentCharacterswhole; structured-output agents would inherit the avatarPath data URLs from history regardless of whether<current_game_state>is included.buildKnowledgeRouterQueryatsrc/engine/agents-runtime/knowledge/knowledge-router.ts- serializescontext.gameStateverbatim into the router query; latent until the knowledge router is enabled on an imported chat.Co-locating the rule in a named helper makes it findable by symbol search and keeps future serialization sites a one-import-and-pass-the-replacer change rather than rediscovering the rule per-site.
Verification
pnpm check:frontend,pnpm check:architecture,pnpm check:docsall pass locally (595 modules, 2120 dependencies cruised).pnpm tauri devon Windows against an imported pre-refactor profile (the exact repro from the issue: roleplay chat withactiveAgentIds: ["world-state", "quest", "character-tracker", "persona-stats"]). Before the fix: all four agent results returnedsuccess: falsewith the prompt-too-long error and both side panels stayed empty. After the fix: all four agents complete normally, the agent activity panel shows the four thought bubbles, and the tracker panel populates with world / character / quest / persona data. Re-verified after the helper extraction; behavior unchanged.Out of scope
A second, separate UX bug is visible in passing: when every agent in a turn fails, the user sees only the empty-state panels - the failure surface (
setFailedAgentFailures/failedAgentTypesinagent.store.ts) is defined but never called fromapplyAgentResultEffects, so genuine agent failures are silent. That made this bug much harder to spot than it should have been. Filed as #1192 to track separately; intentionally left out of this PR to keep the diff focused on the actual root cause.Fixes #1188.
Summary by CodeRabbit
Bug Fixes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.