Skip to content

Commit ee88a30

Browse files
committed
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.
1 parent 32c4a5c commit ee88a30

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

packages/plugin/src/agents/magic-context-prompt.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ Use \`ctx_note\` for deferred intentions — things to tackle later, not right n
2222
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.
2323
Use \`ctx_search\` to search across project memories, session facts, and conversation history from one query.
2424
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.
2532
NEVER drop large ranges blindly (e.g., "1-50"). Review each tag before deciding.
2633
NEVER drop user messages — they are short and will be summarized by compartmentalization automatically. Dropping them loses context the historian needs.
2734
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
3239
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).
3340
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.
3441
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.`;
3650

3751
const SISYPHUS_SECTION = `
3852
### Reduction Triggers

0 commit comments

Comments
 (0)