Skip to content

Commit 7de0666

Browse files
committed
cleanup: simplify prompts to compress-only
1 parent acd72b9 commit 7de0666

3 files changed

Lines changed: 7 additions & 18 deletions

File tree

lib/hooks.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ export function createSystemPromptHandler(
8787

8888
output.system.push(
8989
renderSystemPrompt({
90-
compress: true,
9190
manual: state.manualMode,
9291
}),
9392
)

lib/prompts/index.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,16 @@ import { NUDGE } from "./_codegen/nudge.generated"
44
import { COMPRESS as COMPRESS_TOOL_SPEC } from "./_codegen/compress.generated"
55

66
export interface ToolFlags {
7-
compress: boolean
87
manual: boolean
98
}
109

11-
function processConditionals(template: string, flags: ToolFlags): string {
12-
const tools = ["manual", "compress"] as const
13-
const enabled = {
14-
manual: flags.manual,
15-
compress: flags.compress,
16-
}
17-
18-
let result = template
10+
function renderSystemPromptInternal(manual: boolean): string {
11+
let result = SYSTEM_PROMPT
1912
result = result.replace(/\/\/.*?\/\//g, "")
2013

21-
for (const tool of tools) {
22-
const regex = new RegExp(`<${tool}>([\\s\\S]*?)</${tool}>`, "g")
23-
result = result.replace(regex, (_, content) => (enabled[tool] ? content : ""))
14+
if (!manual) {
15+
const regex = new RegExp(`<manual>[\\s\\S]*?</manual>`, "g")
16+
result = result.replace(regex, "")
2417
}
2518

2619
return result.replace(/\n([ \t]*\n)+/g, "\n\n").trim()
@@ -38,10 +31,7 @@ function extractInstruction(content: string, name: string): string {
3831
}
3932

4033
export function renderSystemPrompt(flags?: ToolFlags): string {
41-
return processConditionals(SYSTEM_PROMPT, {
42-
compress: flags?.compress ?? true,
43-
manual: flags?.manual ?? false,
44-
})
34+
return renderSystemPromptInternal(flags?.manual ?? false)
4535
}
4636

4737
export function renderNudge(mode: NudgeMode = "frequency"): string {

lib/prompts/system.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ It is of your responsibility to keep a sharp, high-quality context window for op
5454
<manual><instruction name=manual_mode policy_level=critical>
5555
Manual mode is enabled. Do NOT use compress unless the user has explicitly triggered it through a manual marker.
5656

57-
<compress>Only use the compress tool after seeing `<compress triggered manually>` in the current user instruction context.</compress>
57+
Only use the compress tool after seeing `<compress triggered manually>` in the current user instruction context.
5858

5959
After completing a manually triggered context-management action, STOP IMMEDIATELY. Do NOT continue with any task execution. End your response right after the tool use completes and wait for the next user input.
6060
</instruction></manual>

0 commit comments

Comments
 (0)