mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2941] [Issue]: Text inserted by {{agent::TYPE}} is re-run as macros (can set variables or trigger the dice freeze) #1518
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#1518
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 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2941
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
Text pulled into the prompt by
{{agent::TYPE}}(an agent's or tracker's cached output) is then treated as macros and executed. So if an agent/tracker ever produces text that contains{{…}}— which the model can do on its own — those macros run: they can silently set variables, or trigger the runaway dice loop and freeze the app.How to reproduce (try it yourself)
{{agent::TYPE}}(e.g. in a preset or character field).{{roll:999999999d6}}(or{{setvar::pwned::1}}).You'll see: with
{{roll:999999999d6}}the request freezes (the dice loop runs); with{{setvar::pwned::1}}the variablepwnedis now set even though no card/preset asked for it.Expected: an agent's text output should be inserted as plain text, not re-interpreted as macros.
Where it is
packages/shared/src/utils/macro-engine.ts—resolveMacrossubstitutes{{agent::TYPE}}at lines 892–894, but the variable, random, and dice handlers (907–961) run after that on the same string, so anything the agent inserted is now eligible for macro processing.What's happening
resolveMacrosis one single pass: substituted values are not marked "already resolved," so untrusted text inserted mid-pass (agent output here) is processed by the remaining macro stages. This is the same shape as macros leaking from character cards/lorebooks generally, but{{agent::TYPE}}makes it reachable from model-generated text.Suggested fix
Insert
{{agent::TYPE}}output as inert text — either resolve it in a final pass after all other macros, or escape/neutralize any{{}}in agent output before substituting it. More broadly, substituted values from untrusted sources should not be re-fed into the macro engine.Found by a code review of v2.0.6. The mechanism is certain; the trigger depends on the agent output containing a macro — please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 28, 2026):
Fixed on staging:
{{agent::TYPE}}output is now substituted after executable macro passes, so agent/tracker text is inserted inertly instead of re-running dice/variable macros.