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
feat(plugin): add ctx_search usage guidance to agent prompts
Agents now get explicit 'search before asking' guidance with concrete
examples (project paths, architectural decisions, config details, prior
implementations, earlier conversations). Applied to both ctx_reduce
enabled and disabled prompt variants.
Copy file name to clipboardExpand all lines: packages/plugin/src/agents/magic-context-prompt.ts
+15-1Lines changed: 15 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,13 @@ Use \`ctx_note\` for deferred intentions — things to tackle later, not right n
22
22
Use \`ctx_memory\` to manage cross-session project memories. Write new memories or delete stale ones. Memories persist across sessions and are automatically injected into new sessions.
23
23
Use \`ctx_search\` to search across project memories, session facts, and conversation history from one query.
24
24
Use \`ctx_expand\` to decompress a compartment range to see the original conversation transcript. Use \`start\`/\`end\` from \`<compartment start=N end=M>\` attributes. Returns the compacted U:/A: transcript for that message range, capped at ~15K tokens.
25
+
**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:
26
+
- Can't remember where a related codebase or dependency lives → \`ctx_search(query="opencode source code path")\`
27
+
- Forgot a prior architectural decision or constraint → \`ctx_search(query="why did we choose SQLite over postgres")\`
28
+
- Need a config value, API key location, or environment detail → \`ctx_search(query="embedding provider configuration")\`
29
+
- Looking for how something was implemented previously → \`ctx_search(query="how does the dreamer lease work")\`
30
+
- Want to recall what was decided in an earlier conversation → \`ctx_search(query="dashboard release signing setup")\`
31
+
\`ctx_search\` returns ranked results from memories, session facts, and raw message history. Use message ordinals from results with \`ctx_expand\` to retrieve surrounding conversation context.
25
32
NEVER drop large ranges blindly (e.g., "1-50"). Review each tag before deciding.
26
33
NEVER drop user messages — they are short and will be summarized by compartmentalization automatically. Dropping them loses context the historian needs.
27
34
NEVER drop assistant text messages unless they are exceptionally large. Your conversation messages are lightweight; only large tool outputs are worth dropping.
@@ -32,7 +39,14 @@ const BASE_INTRO_NO_REDUCE = `Messages and tool outputs are tagged with §N§ id
32
39
Use \`ctx_note\` for deferred intentions — things to tackle later, not right now. NOT for task tracking (use todos). Notes survive context compression and you'll be reminded at natural work boundaries (after commits, historian runs, todo completion).
33
40
Use \`ctx_memory\` to manage cross-session project memories. Write new memories or delete stale ones. Memories persist across sessions and are automatically injected into new sessions.
34
41
Use \`ctx_search\` to search across project memories, session facts, and conversation history from one query.
35
-
Use \`ctx_expand\` to decompress a compartment range to see the original conversation transcript. Use \`start\`/\`end\` from \`<compartment start=N end=M>\` attributes. Returns the compacted U:/A: transcript for that message range, capped at ~15K tokens.`;
42
+
Use \`ctx_expand\` to decompress a compartment range to see the original conversation transcript. Use \`start\`/\`end\` from \`<compartment start=N end=M>\` attributes. Returns the compacted U:/A: transcript for that message range, capped at ~15K tokens.
43
+
**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:
44
+
- Can't remember where a related codebase or dependency lives → \`ctx_search(query="opencode source code path")\`
45
+
- Forgot a prior architectural decision or constraint → \`ctx_search(query="why did we choose SQLite over postgres")\`
46
+
- Need a config value, API key location, or environment detail → \`ctx_search(query="embedding provider configuration")\`
47
+
- Looking for how something was implemented previously → \`ctx_search(query="how does the dreamer lease work")\`
48
+
- Want to recall what was decided in an earlier conversation → \`ctx_search(query="dashboard release signing setup")\`
49
+
\`ctx_search\` returns ranked results from memories, session facts, and raw message history. Use message ordinals from results with \`ctx_expand\` to retrieve surrounding conversation context.`;
0 commit comments