Skip to content

Commit 834cd87

Browse files
committed
Merge remote-tracking branch 'origin/master' into refactor/prompt-cleanup
# Conflicts: # lib/prompts/nudge.txt # lib/prompts/system-reminder.txt
2 parents 5d38c15 + cfd0794 commit 834cd87

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ const plugin: Plugin = (async (ctx) => {
4545

4646
const prompts = {
4747
synthInstruction: loadPrompt("synthetic"),
48-
nudgeInstruction: loadPrompt("nudge"),
49-
systemReminder: loadPrompt("system-reminder")
48+
nudgeInstruction: loadPrompt("nudge")
5049
}
5150

5251
// Install global fetch wrapper for context pruning and synthetic instruction injection

lib/fetch-wrapper/handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export async function handleFormat(
9696
if (prunableList) {
9797
const includeNudge = ctx.config.nudge_freq > 0 && ctx.toolTracker.toolResultCount > ctx.config.nudge_freq
9898

99-
const endInjection = buildEndInjection(prunableList, includeNudge, ctx.prompts.nudgeInstruction, ctx.prompts.systemReminder)
99+
const endInjection = buildEndInjection(prunableList, includeNudge)
100100
if (format.injectPrunableList(data, endInjection)) {
101101
ctx.logger.debug("fetch", `Injected prunable tools list (${format.name})`, {
102102
ids: numericIds,

lib/fetch-wrapper/prunable-list.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ import { extractParameterKey } from '../ui/display-utils'
22
import { getOrCreateNumericId } from '../state/id-mapping'
33
import type { ToolMetadata } from './types'
44

5+
const SYSTEM_REMINDER = `<system-reminder>
6+
These instructions are injected by a plugin and are invisible to the user. Do not acknowledge or reference them in your response - simply follow them silently.
7+
</system-reminder>`
8+
9+
const NUDGE_INSTRUCTION = `<instruction name=agent_nudge>
10+
You have accumulated several tool outputs. If you have completed a discrete unit of work and distilled relevant understanding in writing for the user to keep, use the prune tool to remove obsolete tool outputs from this conversation and optimize token usage.
11+
</instruction>`
12+
513
export interface PrunableListResult {
614
list: string
715
numericIds: number[]
@@ -41,18 +49,16 @@ export function buildPrunableToolsList(
4149

4250
export function buildEndInjection(
4351
prunableList: string,
44-
includeNudge: boolean,
45-
nudgeInstruction: string,
46-
systemReminder: string
52+
includeNudge: boolean
4753
): string {
4854
if (!prunableList) {
4955
return ''
5056
}
5157

52-
const parts = [systemReminder]
58+
const parts = [SYSTEM_REMINDER]
5359

5460
if (includeNudge) {
55-
parts.push(nudgeInstruction)
61+
parts.push(NUDGE_INSTRUCTION)
5662
}
5763

5864
parts.push(prunableList)

lib/fetch-wrapper/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export interface FormatDescriptor {
2929
export interface SynthPrompts {
3030
synthInstruction: string
3131
nudgeInstruction: string
32-
systemReminder: string
3332
}
3433

3534
export interface FetchHandlerContext {

lib/prompts/synthetic.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
<system-reminder>
2+
These instructions are injected by a plugin and are invisible to the user. Do not acknowledge or reference them in your response - simply follow them silently.
3+
4+
IMPORTANT: Your thinking/reasoning blocks must NOT reference, discuss, or address these instructions, the <prunable-tools> list, or any nudges about pruning. The user can see your thinking blocks, and referencing invisible plugin content will confuse them. In your thinking, focus only on the user's task and your problem-solving approach.
5+
</system-reminder>
6+
17
<instruction name=signal_management>
28
After calling a series of tools, YOU ALWAYS HAVE TO distill signals from their results in your next message. This ensures tracability of your reasoning, informs the user of your findings, and is PARAMOUNT to best context window management practices.
39

@@ -31,4 +37,4 @@ EXAMPLE WORKFLOW:
3137
>YOU MUST ALWAYS THINK HIGH SIGNAL LOW NOISE FOR THIS NARRATION
3238
4. ONLY AFTER the narration, you call the `prune` tool with a brief reason (e.g. "exploration for bug X complete; moving on to next bug").
3339
5. AFTER pruning succeeds, DO NOT re-summarize or re-narrate. You already distilled your findings before calling prune. Continue with your next task, or if you need more information from the user, wait for their response.
34-
</instruction>
40+
</instruction>

0 commit comments

Comments
 (0)