From 7ebe524659e62f62aa58a79fc22974ca24f5e856 Mon Sep 17 00:00:00 2001 From: Daniel Smolsky Date: Mon, 19 Jan 2026 12:15:49 -0500 Subject: [PATCH 1/2] docs: clarify context_info tool injection mechanism - Explain that context_info is an environment-only tool - Add explicit instruction that model must not call it - Correct message role from user to assistant --- lib/prompts/system/both.ts | 6 ++++-- lib/prompts/system/discard.ts | 6 ++++-- lib/prompts/system/extract.ts | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/prompts/system/both.ts b/lib/prompts/system/both.ts index e101e38..2ab48ad 100644 --- a/lib/prompts/system/both.ts +++ b/lib/prompts/system/both.ts @@ -2,7 +2,9 @@ export const SYSTEM_PROMPT_BOTH = ` ENVIRONMENT -You are operating in a context-constrained environment and thus must proactively manage your context window using the \`discard\` and \`extract\` tools. A 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. +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 list after each assistant turn. Use this information when deciding what to prune. + +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. TWO TOOLS FOR CONTEXT MANAGEMENT - \`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 -After each assistant turn, the environment may inject a user message containing a 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. +After each assistant turn, the environment calls the \`context_info\` tool to inject an assistant message containing a list and optional nudge instruction. This tool is only available to the environment - you do not have access to it. The \`discard\` and \`extract\` tools also return a confirmation message listing what was pruned. CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE: - NEVER reference the prune encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the prune encouragement appears. diff --git a/lib/prompts/system/discard.ts b/lib/prompts/system/discard.ts index b164114..6822513 100644 --- a/lib/prompts/system/discard.ts +++ b/lib/prompts/system/discard.ts @@ -2,7 +2,9 @@ export const SYSTEM_PROMPT_DISCARD = ` ENVIRONMENT -You are operating in a context-constrained environment and thus must proactively manage your context window using the \`discard\` tool. A 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. +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 list after each assistant turn. Use this information when deciding what to discard. + +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. CONTEXT MANAGEMENT TOOL - \`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 -After each assistant turn, the environment may inject a user message containing a 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. +After each assistant turn, the environment calls the \`context_info\` tool to inject an assistant message containing a list and optional nudge instruction. This tool is only available to the environment - you do not have access to it. The \`discard\` tool also returns a confirmation message listing what was discarded. CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE: - NEVER reference the discard encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the discard encouragement appears. diff --git a/lib/prompts/system/extract.ts b/lib/prompts/system/extract.ts index c73960e..20bb7ff 100644 --- a/lib/prompts/system/extract.ts +++ b/lib/prompts/system/extract.ts @@ -2,7 +2,9 @@ export const SYSTEM_PROMPT_EXTRACT = ` ENVIRONMENT -You are operating in a context-constrained environment and thus must proactively manage your context window using the \`extract\` tool. A 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. +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 list after each assistant turn. Use this information when deciding what to extract. + +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. CONTEXT MANAGEMENT TOOL - \`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 -After each assistant turn, the environment may inject a user message containing a 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. +After each assistant turn, the environment calls the \`context_info\` tool to inject an assistant message containing a list and optional nudge instruction. This tool is only available to the environment - you do not have access to it. The \`extract\` tool also returns a confirmation message listing what was extracted. CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE: - NEVER reference the extract encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the extract encouragement appears. From 11b6843943bde16164420915710947fd6f0b89b4 Mon Sep 17 00:00:00 2001 From: Daniel Smolsky Date: Mon, 19 Jan 2026 12:57:49 -0500 Subject: [PATCH 2/2] fix: remove redundant sentence about tool confirmation messages The bullet point 'NEVER acknowledge discard/extract tool output' already covers this behavior, making the sentence redundant and awkwardly placed. --- lib/prompts/system/both.ts | 2 +- lib/prompts/system/discard.ts | 2 +- lib/prompts/system/extract.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/prompts/system/both.ts b/lib/prompts/system/both.ts index 2ab48ad..f5551aa 100644 --- a/lib/prompts/system/both.ts +++ b/lib/prompts/system/both.ts @@ -44,7 +44,7 @@ There may be tools in session context that do not appear in the -After each assistant turn, the environment calls the \`context_info\` tool to inject an assistant message containing a list and optional nudge instruction. This tool is only available to the environment - you do not have access to it. The \`discard\` and \`extract\` tools also return a confirmation message listing what was pruned. +After each assistant turn, the environment calls the \`context_info\` tool to inject an assistant message containing a list and optional nudge instruction. This tool is only available to the environment - you do not have access to it. CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE: - NEVER reference the prune encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the prune encouragement appears. diff --git a/lib/prompts/system/discard.ts b/lib/prompts/system/discard.ts index 6822513..1bf661f 100644 --- a/lib/prompts/system/discard.ts +++ b/lib/prompts/system/discard.ts @@ -35,7 +35,7 @@ There may be tools in session context that do not appear in the -After each assistant turn, the environment calls the \`context_info\` tool to inject an assistant message containing a list and optional nudge instruction. This tool is only available to the environment - you do not have access to it. The \`discard\` tool also returns a confirmation message listing what was discarded. +After each assistant turn, the environment calls the \`context_info\` tool to inject an assistant message containing a list and optional nudge instruction. This tool is only available to the environment - you do not have access to it. CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE: - NEVER reference the discard encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the discard encouragement appears. diff --git a/lib/prompts/system/extract.ts b/lib/prompts/system/extract.ts index 20bb7ff..859f36d 100644 --- a/lib/prompts/system/extract.ts +++ b/lib/prompts/system/extract.ts @@ -35,7 +35,7 @@ There may be tools in session context that do not appear in the -After each assistant turn, the environment calls the \`context_info\` tool to inject an assistant message containing a list and optional nudge instruction. This tool is only available to the environment - you do not have access to it. The \`extract\` tool also returns a confirmation message listing what was extracted. +After each assistant turn, the environment calls the \`context_info\` tool to inject an assistant message containing a list and optional nudge instruction. This tool is only available to the environment - you do not have access to it. CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE: - NEVER reference the extract encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the extract encouragement appears.