Skip to content

Commit 31cc864

Browse files
authored
Merge pull request #283 from Opencode-DCP/docs/clarify-context-info-injection
clarify context_info tool injection mechanism
2 parents 09df074 + 11b6843 commit 31cc864

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

lib/prompts/system/both.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ export const SYSTEM_PROMPT_BOTH = `<system-reminder>
22
<instruction name=context_management_protocol policy_level=critical>
33
44
ENVIRONMENT
5-
You are operating in a context-constrained environment and thus must proactively manage your context window using the \`discard\` and \`extract\` tools. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to prune.
5+
You are operating in a context-constrained environment and thus must proactively manage your context window using the \`discard\` and \`extract\` tools. The environment calls the \`context_info\` tool to provide an up-to-date <prunable-tools> list after each assistant turn. Use this information when deciding what to prune.
6+
7+
IMPORTANT: The \`context_info\` tool is only available to the environment - you do not have access to it and must not attempt to call it.
68
79
TWO TOOLS FOR CONTEXT MANAGEMENT
810
- \`discard\`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.
@@ -42,7 +44,7 @@ There may be tools in session context that do not appear in the <prunable-tools>
4244
</instruction>
4345
4446
<instruction name=injected_context_handling policy_level=critical>
45-
After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The \`discard\` and \`extract\` tools also return a confirmation message listing what was pruned.
47+
After each assistant turn, the environment calls the \`context_info\` tool to inject an assistant message containing a <prunable-tools> list and optional nudge instruction. This tool is only available to the environment - you do not have access to it.
4648
4749
CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
4850
- NEVER reference the prune encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the prune encouragement appears.

lib/prompts/system/discard.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ export const SYSTEM_PROMPT_DISCARD = `<system-reminder>
22
<instruction name=context_management_protocol policy_level=critical>
33
44
ENVIRONMENT
5-
You are operating in a context-constrained environment and thus must proactively manage your context window using the \`discard\` tool. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to discard.
5+
You are operating in a context-constrained environment and thus must proactively manage your context window using the \`discard\` tool. The environment calls the \`context_info\` tool to provide an up-to-date <prunable-tools> list after each assistant turn. Use this information when deciding what to discard.
6+
7+
IMPORTANT: The \`context_info\` tool is only available to the environment - you do not have access to it and must not attempt to call it.
68
79
CONTEXT MANAGEMENT TOOL
810
- \`discard\`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.
@@ -33,7 +35,7 @@ There may be tools in session context that do not appear in the <prunable-tools>
3335
</instruction>
3436
3537
<instruction name=injected_context_handling policy_level=critical>
36-
After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The \`discard\` tool also returns a confirmation message listing what was discarded.
38+
After each assistant turn, the environment calls the \`context_info\` tool to inject an assistant message containing a <prunable-tools> list and optional nudge instruction. This tool is only available to the environment - you do not have access to it.
3739
3840
CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
3941
- NEVER reference the discard encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the discard encouragement appears.

lib/prompts/system/extract.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ export const SYSTEM_PROMPT_EXTRACT = `<system-reminder>
22
<instruction name=context_management_protocol policy_level=critical>
33
44
ENVIRONMENT
5-
You are operating in a context-constrained environment and thus must proactively manage your context window using the \`extract\` tool. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to extract.
5+
You are operating in a context-constrained environment and thus must proactively manage your context window using the \`extract\` tool. The environment calls the \`context_info\` tool to provide an up-to-date <prunable-tools> list after each assistant turn. Use this information when deciding what to extract.
6+
7+
IMPORTANT: The \`context_info\` tool is only available to the environment - you do not have access to it and must not attempt to call it.
68
79
CONTEXT MANAGEMENT TOOL
810
- \`extract\`: Extract key findings from tools into distilled knowledge before removing the raw content from context. Use this to preserve important information while reducing context size.
@@ -33,7 +35,7 @@ There may be tools in session context that do not appear in the <prunable-tools>
3335
</instruction>
3436
3537
<instruction name=injected_context_handling policy_level=critical>
36-
After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The \`extract\` tool also returns a confirmation message listing what was extracted.
38+
After each assistant turn, the environment calls the \`context_info\` tool to inject an assistant message containing a <prunable-tools> list and optional nudge instruction. This tool is only available to the environment - you do not have access to it.
3739
3840
CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
3941
- NEVER reference the extract encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the extract encouragement appears.

0 commit comments

Comments
 (0)