You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(skill-memory): gate ctx_memory cross-ref in skill guidance when memory off
Rebase-onto-v0.29.0 resolution completion. Upstream ab4f01c added a
memory.enabled gate that drops ALL ctx_memory mentions from the system
prompt when memory is off (ctx_memory is then unregistered). The skill-memory
guidance carried a 'those belong in ctx_memory' cross-reference that violated
the new contract (buildMagicContextSection memory-gating tests). Parameterized
ctxSkillMemoryGuidance(memoryEnabled) so the cross-ref drops when memory is off;
skill-memory itself stays ungated (independent store).
Copy file name to clipboardExpand all lines: packages/plugin/src/agents/magic-context-prompt.ts
+12-5Lines changed: 12 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -70,13 +70,20 @@ function memoryGuidanceBlock(memoryEnabled: boolean): string {
70
70
// `ctx_skill_recall` rehydrates accumulated notes for a skill without re-loading it.
71
71
// Distinct from `ctx_memory`, which captures general project knowledge (not tied
72
72
// to a specific skill). NOT gated on memory.enabled — skill-memory is an
73
-
// independent store (its own table + tool-result-tail injection).
74
-
constCTX_SKILL_MEMORY_GUIDANCE=`Use \`ctx_skill_note\` after using a skill when you hit a non-obvious issue, found a better approach, or fixed a skill-specific error. Skip routine successes — only record gotchas, discoveries, fixes, and workflow steps that would save time on the next use.
73
+
// independent store (its own table + tool-result-tail injection) — BUT the
74
+
// `ctx_memory` cross-reference is dropped when memory is off, since ctx_memory is
75
+
// then unregistered and pointing at it would be misleading (mirrors MEMORY_GUIDANCE).
? "Do NOT use `ctx_skill_note` for general project observations — those belong in `ctx_memory`."
79
+
: "Do NOT use `ctx_skill_note` for general project observations.";
80
+
return`Use \`ctx_skill_note\` after using a skill when you hit a non-obvious issue, found a better approach, or fixed a skill-specific error. Skip routine successes — only record gotchas, discoveries, fixes, and workflow steps that would save time on the next use.
75
81
Example: \`ctx_skill_note({skill: 'trilium', intent: 'bulk-retag a subtree', kind: 'gotcha', delta: 'ETAPI note PUT needs Content-Type: text/plain even for HTML content'})\`
76
82
Example: \`ctx_skill_note({skill: 'test-driven-development', intent: 'fix flaky auth test', kind: 'fix', delta: 'Always mock Date.now() in auth tests — real timers cause intermittent failures'})\`
77
-
Do NOT use \`ctx_skill_note\` for general project observations — those belong in \`ctx_memory\`.
83
+
${generalObservationsLine}
78
84
79
85
Use \`ctx_skill_recall\` to explicitly query accumulated notes for a skill without re-loading it. Call it when you want to recall gotchas/discoveries for a skill you have already loaded this session, or when you need notes without triggering a full skill load. Returns the \`<skill-memory>\` block directly as a tool result. Example: \`ctx_skill_recall({skill: 'trilium', intent: 'bulk-retag a subtree'})\`.`;
86
+
}
80
87
81
88
constBASE_INTRO=(
82
89
protectedTags: number,
@@ -85,7 +92,7 @@ const BASE_INTRO = (
85
92
Use \`ctx_reduce\` to mark spent tagged content as discardable and reclaim space. Marking is NOT an immediate delete — it queues the content, which stays fully visible until space is actually needed (as soon as the next turn if you're already under pressure, much later if not), so mark a tool output as soon as you're done with it rather than hoarding the call for the end of the turn. The last ${protectedTags} tags are protected (marking one just queues it until it ages out). Syntax: "3-5", "1,2,9", or "1-5,8,12-15".
86
93
Do not announce or narrate \`ctx_reduce\` drops — just call the tool silently. Saying "I'll drop these outputs" wastes tokens the user does not care about.
Use \`ctx_search\` to search across project memories, indexed git commits, and this session's full conversation history (including compacted parts) from one query.
90
97
Use \`ctx_expand\` to recover the raw conversation behind a \`<compartment>\` summary in \`<session-history>\` — pass its \`start\`/\`end\` attributes when the summary is not enough (exact wording, values, error text).
91
98
**Search before asking the user**: If you can't remember or don't know something that might have been discussed before or stored in project memory, use \`ctx_search\` before asking the user. Examples:
@@ -107,7 +114,7 @@ Before your turn finishes, consider using \`ctx_reduce\` to drop large tool outp
107
114
* a tagging system they can't observe just wastes tokens and (empirically) primes
108
115
* some models to emit malformed `§N">§` tokens at the start of their own text. */
Use \`ctx_search\` to search across project memories, indexed git commits, and this session's full conversation history (including compacted parts) from one query.
112
119
Use \`ctx_expand\` to recover the raw conversation behind a \`<compartment>\` summary in \`<session-history>\` — pass its \`start\`/\`end\` attributes when the summary is not enough (exact wording, values, error text).
113
120
**Search before asking the user**: If you can't remember or don't know something that might have been discussed before or stored in project memory, use \`ctx_search\` before asking the user. Examples:
0 commit comments