Skip to content

Commit 7068b57

Browse files
authored
fix: Reduce agent eagerness to re-enter plan mode mid-task (#1208)
1 parent 634ef13 commit 7068b57

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
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 & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from "../hooks";
1919
import type { CodeExecutionMode } from "../tools";
2020
import type { EffortLevel } from "../types";
21+
import { APPENDED_INSTRUCTIONS } from "./instructions";
2122
import { DEFAULT_MODEL } from "./models";
2223
import type { SettingsManager } from "./settings";
2324

@@ -47,27 +48,21 @@ export interface BuildOptionsParams {
4748
effort?: EffortLevel;
4849
}
4950

50-
const BRANCH_NAMING_INSTRUCTIONS = `
51-
# Branch Naming
52-
53-
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.
54-
`;
55-
5651
export function buildSystemPrompt(
5752
customPrompt?: unknown,
5853
): Options["systemPrompt"] {
5954
const defaultPrompt: Options["systemPrompt"] = {
6055
type: "preset",
6156
preset: "claude_code",
62-
append: BRANCH_NAMING_INSTRUCTIONS,
57+
append: APPENDED_INSTRUCTIONS,
6358
};
6459

6560
if (!customPrompt) {
6661
return defaultPrompt;
6762
}
6863

6964
if (typeof customPrompt === "string") {
70-
return customPrompt + BRANCH_NAMING_INSTRUCTIONS;
65+
return customPrompt + APPENDED_INSTRUCTIONS;
7166
}
7267

7368
if (
@@ -78,7 +73,7 @@ export function buildSystemPrompt(
7873
) {
7974
return {
8075
...defaultPrompt,
81-
append: customPrompt.append + BRANCH_NAMING_INSTRUCTIONS,
76+
append: customPrompt.append + APPENDED_INSTRUCTIONS,
8277
};
8378
}
8479

0 commit comments

Comments
 (0)