Skip to content

Commit 37db874

Browse files
committed
Reduce agent eagerness to re-enter plan mode mid-task
1 parent bd915de commit 37db874

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const BRANCH_NAMING = `
2+
# Branch Naming
3+
4+
When working in a detached HEAD state, create a descriptive branch name based on the work being done before committing. Do this automatically without asking the user.
5+
`;
6+
7+
const PLAN_MODE = `
8+
# Plan Mode
9+
10+
Only enter plan mode (EnterPlanMode) when the user is requesting a significant change in approach or direction mid-task. Do NOT enter plan mode for:
11+
- Confirmations or approvals ("yes", "looks good", "continue", "go ahead")
12+
- Minor clarifications or small adjustments
13+
- Answers to questions you asked (unless you are still in the initial planning phase and have not yet started executing)
14+
- Feedback that does not require replanning
15+
16+
When in doubt, continue executing and incorporate the feedback inline.
17+
`;
18+
19+
export const APPENDED_INSTRUCTIONS = BRANCH_NAMING + PLAN_MODE;

packages/agent/src/adapters/claude/session/options.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
type OnModeChange,
1818
} from "../hooks.js";
1919
import type { CodeExecutionMode } from "../tools.js";
20+
import { APPENDED_INSTRUCTIONS } from "./instructions.js";
2021
import { DEFAULT_MODEL } from "./models.js";
2122
import type { SettingsManager } from "./settings.js";
2223

@@ -45,27 +46,22 @@ export interface BuildOptionsParams {
4546
onProcessExited?: (pid: number) => void;
4647
}
4748

48-
const BRANCH_NAMING_INSTRUCTIONS = `
49-
# Branch Naming
50-
51-
When working in a detached HEAD state, create a descriptive branch name based on the work being done before committing. Do this automatically without asking the user.
52-
`;
5349

5450
export function buildSystemPrompt(
5551
customPrompt?: unknown,
5652
): Options["systemPrompt"] {
5753
const defaultPrompt: Options["systemPrompt"] = {
5854
type: "preset",
5955
preset: "claude_code",
60-
append: BRANCH_NAMING_INSTRUCTIONS,
56+
append: APPENDED_INSTRUCTIONS,
6157
};
6258

6359
if (!customPrompt) {
6460
return defaultPrompt;
6561
}
6662

6763
if (typeof customPrompt === "string") {
68-
return customPrompt + BRANCH_NAMING_INSTRUCTIONS;
64+
return customPrompt + APPENDED_INSTRUCTIONS;
6965
}
7066

7167
if (
@@ -76,7 +72,7 @@ export function buildSystemPrompt(
7672
) {
7773
return {
7874
...defaultPrompt,
79-
append: customPrompt.append + BRANCH_NAMING_INSTRUCTIONS,
75+
append: customPrompt.append + APPENDED_INSTRUCTIONS,
8076
};
8177
}
8278

0 commit comments

Comments
 (0)