mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3448] [Feature]: Support relocation macros ({{memories}}, {{lorebook}}, {{commands}}, ...) in {{#if}} conditions #1863
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#1863
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 (Jul 10, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3448
What problem does this solve?
The Conversation-mode relocation macros —
{{context}}/{{status}},{{commands}},{{reactRules}},{{memories}},{{lorebook}}— cannot be tested inside{{#if}}conditions. A preset like:always renders the block, even when there are no memories, so the
## Memoriesheader shows with nothing under it.Why: relocation macros are not resolved by the shared macro engine at all — their content is injected by the route (
replaceConversationContextMacro) afterresolveMacroshas already processed the{{#if}}. At condition-evaluation time the operand resolves to the literal token string ("memories"), so"memories" != ""is trivially true. This is unlike every value macro ({{char_about}},{{date}},{{agent::TYPE}}, …), which the engine can resolve. (Filed as the follow-up to the{{#if}}macro-resolution fixes in #3435.)Users building modular Conversation presets want conditional headers/wrappers around these blocks, and want
{{#if}}to behave consistently across all macros.Proposed solution
Add a generic, opt-in deferral hook to the shared macro engine so a caller can mark certain
{{#if}}operands as "resolved later," reusing the exact mechanism the engine already uses to defer per-character macros in group chats:resolveMacrosgains an optionaldeferConditionalOperand?: (operand: string) => boolean. When a{{#if}}condition depends on such an operand, the engine encodes the block as a deferred token (leaving inner macros raw) instead of evaluating it. The engine stays mode-agnostic — it never hardcodes conversation macro names.This makes
{{#if memories != ""}},{{#if lorebook contains "x"}}, etc. work with the full operator set, consistent with all other macros. Conditions that mix a character macro and a relocation macro in the same comparison are out of scope (documented).Also required: the slot detector must recognize a relocation alias used only as an
{{#if}}operand (a header-only block with no bare{{memories}}), so retrieval still runs.Alternatives considered
{{#if:memories}}…{{/if:memories}}the route strips/keeps): ~40 LOC, near-zero risk, but non-empty only (no operators) and a second conditional syntax to learn — re-introduces the inconsistency this report is about.Additional context
Follow-up to #3435 (
{{#if}}macro resolution) and the docs in #3437. The engine already has a proven per-character deferral pattern (deferCharacterMacros→encodeDeferredConditional→ decode) to mirror. Implementation is planned as a single focused PR (engine hook + route decode + slot-detection fix + tests), with the dry-run debug preview mirrored so it matches.Template check