Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

prompt improvements for reliable _apply.sh script

Dane Schneider4024f244e072
diff --git a/app/server/model/plan/tell_context.go b/app/server/model/plan/tell_context.go
index e6de46d6..0a91ce84 100644
--- a/app/server/model/plan/tell_context.go
+++ b/app/server/model/plan/tell_context.go
@@ -132,10 +132,10 @@ func (state *activeTellStreamState) formatModelContext(includeMaps, includeTrees
contextMessages = append(contextMessages, fmt.Sprintf("\n\n- _apply.sh:\n\n```\n%s\n```", scriptContent))
if isEmpty && state.isPlanningStage && !state.isContextStage {
- contextMessages = append(contextMessages, "The _apply.sh script is *empty*. You ABSOLUTELY MUST include a '### Commands' section in your response prior to the '### Tasks' section that evaluates whether any commands should be written to _apply.sh during the plan. This is MANDATORY. Do NOT UNDER ANY CIRCUMSTANCES omit this section.")
+ contextMessages = append(contextMessages, "The _apply.sh script is *empty*. You ABSOLUTELY MUST include a '### Commands' section in your response prior to the '### Tasks' section that evaluates whether any commands should be written to _apply.sh during the plan. This is MANDATORY. Do NOT UNDER ANY CIRCUMSTANCES omit this section. If you determine that commands should be added or updated in _apply.sh, you MUST also create a subtask referencing _apply.sh in the '### Tasks' section.")
if execHistory != "" {
- contextMessages = append(contextMessages, "Consider the history of previously executed _apply.sh scripts when determining which commands to include in the new _apply.sh file. Are there any commands that should be run again after code changes? If so, mention them in the '### Commands' section and then include a task to include them in the _apply.sh file in the '### Tasks' section.")
+ contextMessages = append(contextMessages, "Consider the history of previously executed _apply.sh scripts when determining which commands to include in the new _apply.sh file. Are there any commands that should be run again after code changes? If so, mention them in the '### Commands' section and then include a subtask to include them in the _apply.sh file in the '### Tasks' section.")
}
}
}
diff --git a/app/server/model/prompts/apply_exec.go b/app/server/model/prompts/apply_exec.go
index b65c9c37..0746665b 100644
--- a/app/server/model/prompts/apply_exec.go
+++ b/app/server/model/prompts/apply_exec.go
@@ -343,7 +343,7 @@ When planning tasks (and subtasks) that involve command execution, you must cons
- Plan command ordering carefully
### 2. After Reset (Post-Success)
-- **Script Empties**: Once ` + "`_apply.sh`" + ` has been successfully executed, it’s cleared.
+- **Script Empties**: Once ` + "`_apply.sh`" + ` has been successfully executed, it's cleared.
- **No Unnecessary Repeats**: For future tasks, avoid re-adding commands (e.g., reinstalling dependencies) that already ran successfully, unless they are truly needed again.
- **Include Necessary Commands**: If the user continues to iterate on the plan after a successful apply and reset of the _apply.sh script, make sure you *do* add any commands that need to run again for the next iteration. For example, if there is a command that runs the program, and the _apply.sh script has been reset to empty, you must include a step to run the program again.
@@ -374,13 +374,13 @@ When planning tasks (and subtasks) that involve command execution, you must cons
### Good Practices
-- **Check Script State**: If ` + "`_apply.sh`" + ` is not empty, modify existing commands in place. If it’s empty (post-success), add only new or relevant commands.
+- **Check Script State**: If ` + "`_apply.sh`" + ` is not empty, modify existing commands in place. If it's empty (post-success), add only new or relevant commands.
- **Focus on Necessity**: Don't re-run installation for dependencies that were already installed.
- **Be Systematic**: Keep installation commands grouped, then build commands, then run/test commands.
### Final Reminder
-Plan your subtasks so that installation, build, and run commands appear **only where they’re actually required**—and be sure to keep them minimal after the script resets.
+Plan your subtasks so that installation, build, and run commands appear **only where they're actually required**—and be sure to keep them minimal after the script resets.
### Always consider _apply.sh
@@ -408,20 +408,20 @@ If the _apply.sh script previously had a build/run command, and then it was rese
INCORRECT FOLLOW UP:
### Tasks
1. Fix bug in source.c
-Uses: source.c
+Uses: ` + "`source.c`" + `
<PlandexFinish/>
CORRECT FOLLOW UP:
### Commands
-The _apply.sh script is empty after the previous execution. Dependencies have already been installed, so we don't need to install them again. We'll need to build and run the code, so we'll need to add build and run commands to the _apply.sh file.
+The _apply.sh script is empty after the previous execution. Dependencies have already been installed, so we don't need to install them again. We'll need to build and run the code, so we'll need to add build and run commands to the _apply.sh file. I'll add this step to the plan.
### Tasks
1. Fix bug in source.c
-Uses: source.c
+Uses: ` + "`source.c`" + `
-2. Build and run updated code
-Uses: _apply.sh
+2. 🚀 Build and run updated code
+Uses: ` + "`_apply.sh`" + `
<PlandexFinish/>
BEFORE COMPLETING ANY PLAN:
@@ -445,21 +445,23 @@ Each version of _apply.sh that has been executed successfully is included in the
In the '### Commands' section, you MUST assess whether any commands should be written to _apply.sh during the plan based on the reasoning above. Do NOT omit this section.
+If you determine that commands should be added or updated in _apply.sh, you MUST include wording like "I'll add this step to the plan" and then include a subtask referencing _apply.sh in the '### Tasks' section.
+
Example:
I will update the JSON display to use streaming and fix the out-of-memory issue.
### Commands
-_apply.sh is empty. I'll add commands to build and run the updated code.
+_apply.sh is empty. I'll add commands to build and run the updated code. I'll add this step to the plan.
### Tasks
1. Update JSON display to use streaming
-Uses: source.c
+Uses: ` + "`source.c`" + `
-2. Build and run updated code
-Uses: _apply.sh
+2. 🚀 Build and run updated code
+Uses: ` + "`_apply.sh`" + `
<PlandexFinish/>
Another example (with no commands):
@@ -471,7 +473,7 @@ It's not totally clear to me from the context how to build or run the project, s
### Tasks
1. Update JSON display to use streaming
-Uses: source.c
+Uses: ` + "`source.c`" + `
<PlandexFinish/>
@@ -504,9 +506,41 @@ When deciding whether to add commands to _apply.sh (and which ones), follow this
**If you decide to add commands**
* Summarize why in the "### Commands" section (e.g., "We changed ` + "`main.c`" + ` so we need to rebuild and run to verify behavior.").
* Then add a subtask referencing ` + "`_apply.sh`" + ` so the script is updated with exactly those commands.
+* Again, you ABSOLUTELY MUST create a subtask referencing _apply.sh in the tasks list, so the plan actually updates _apply.sh with those commands. This is CRITICAL and cannot be omitted. If the '### Commands' section states that commands should be run, you MUST include wording like "I'll add this step to the plan" and then include a subtask referencing _apply.sh in the tasks list that includes those commands.
**If you decide to skip commands**
* Still provide a "### Commands" section, but briefly note that no commands are needed (or that build/run process is unclear).
+
+---
+INCORRECT:
+
+### Commands
+
+The _apply.sh script is empty. I'll add commands to build and run the updated code.
+
+### Tasks
+
+1. Update JSON display to use streaming
+Uses: ` + "`source.c`" + `
+<PlandexFinish/>
+---
+
+above, the '### Commands' section states that commands should run, but the '### Tasks' section does not include a subtask referencing _apply.sh that includes those commands. This is incorrect.
+
+CORRECT:
+
+### Commands
+
+The _apply.sh script is empty. I'll add commands to build and run the updated code. I'll add this step to the plan.
+
+### Tasks
+
+1. Update JSON display to use streaming
+Uses: ` + "`source.c`" + `
+
+2. 🚀 Build and run updated code
+Uses: ` + "`_apply.sh`" + `
+<PlandexFinish/>
`
const ApplyScriptResetUpdateImplementationPrompt = ApplyScriptResetUpdateSharedPrompt + `
@@ -620,6 +654,23 @@ Remember:
In the '### Commands' section, you MUST assess whether any commands should be written to _apply.sh during the plan based on the reasoning above. Do NOT omit this section.
+CRITICAL: If the "### Commands" section indicates that commands need to be added or updated in _apply.sh, you MUST also create a subtask referencing _apply.sh in the "### Tasks" section.
+
+For example:
+
+### Commands
+
+The _apply.sh script is empty. I'll add commands to build the project and ensure we've fixed the syntax error. I'll add this step to the plan.
+
+### Tasks
+
+1. Fix the syntax error in ui.ts
+Uses: ` + "`ui.ts`" + `
+
+2. 🚀 Build the project with 'npm run build' from package.json
+Uses: ` + "`_apply.sh`" + `, ` + "`package.json`" + `
+<PlandexFinish/>
+
` + ApplyScriptResetUpdatePlanningSummary + ApplyScriptExecutionSummary
const ApplyScriptImplementationPromptSummary = `
diff --git a/app/server/model/prompts/planning.go b/app/server/model/prompts/planning.go
index e0b4dc9e..6eb4bcb3 100644
--- a/app/server/model/prompts/planning.go
+++ b/app/server/model/prompts/planning.go
@@ -50,7 +50,7 @@ func GetPlanningPrompt(params CreatePromptParams) string {
2a. Since *execution mode* is enabled, decide whether you should write any commands to the _apply.sh script in a '### Commands' section.
- Consider the current state and previous history of previously executed _apply.sh scripts when determining which commands should be included in the new _apply.sh file.
- Keep this section brief and high level. Do not write any code or implementation details here. Just assess whether any commands will need to be run during the plan.
- - If you determine that there are commands that should be run, make sure they are included in the '### Tasks' section in the next step.
+ - If you determine that there are commands that should be run, you MUST include wording like "I'll add this step to the plan" and then include a subtask referencing _apply.sh in the '### Tasks' section.
- Follow later instructions on '### Dependencies and Tools' for more details and other instructions related to execution mode and _apply.sh. Consider your instructions on *security considerations*, *local vs. global changes*, *making reasonable assumptions*, and *avoid heavy commands* when deciding whether to include commands in the _apply.sh file.
2b.`
@@ -69,7 +69,7 @@ func GetPlanningPrompt(params CreatePromptParams) string {
prompt += `
### Commands
- We're starting a new plan and no commands have been executed yet. We'll need to install dependencies, then build and run the project.
+ We're starting a new plan and no commands have been executed yet. We'll need to install dependencies, then build and run the project. I'll add this step to the plan.
`
}
@@ -96,7 +96,7 @@ func GetPlanningPrompt(params CreatePromptParams) string {
`
if params.ExecMode {
prompt += `
- 6. Create the _apply.sh file to install dependencies, then build and run the project
+ 6. 🚀 Create the _apply.sh file to install dependencies, then build and run the project
Uses: ` + "`_apply.sh`" + `
`
}
@@ -373,12 +373,12 @@ CRITICAL REMINDERS:
`
if params.ExecMode {
- s += `- Since execution mode is enabled, ALWAYS include a '### Commands' section in your response prior to the '### Tasks' section.
- `
+ s += `- Since execution mode is enabled, ALWAYS include a '### Commands' section in your response prior to the '### Tasks' section.`
}
s += `
- ALWAYS create/update ### Tasks list for any type-A classification
+- If the '### Commands' section indicates that commands should be added or updated in _apply.sh, you MUST also create a subtask referencing _apply.sh in the '### Tasks' section.
- ALWAYS output <PlandexFinish/> immediately after the task list
- ALWAYS end response immediately after <PlandexFinish/>
- NO EXCEPTIONS - Never continue past <PlandexFinish/> for any reason
diff --git a/app/server/model/prompts/user_prompt.go b/app/server/model/prompts/user_prompt.go
index d5290e54..53a88a03 100644
--- a/app/server/model/prompts/user_prompt.go
+++ b/app/server/model/prompts/user_prompt.go
@@ -56,8 +56,8 @@ Uses: ` + "`src/main.rs`"
if params.ExecMode {
s += `
-3. Run the new test with cargo
-Uses: ` + "`src/main.rs`" + `
+3. 🚀 Run the new test with cargo
+Uses: ` + "`_apply.sh`" + `
`
}
@@ -456,11 +456,20 @@ CRITICAL PLANNING RULES:
`
if params.ExecMode {
- s += `You MUST output a ### Commands section before the ### Tasks list`
+ s += `You MUST output a ### Commands section before the ### Tasks list. If you determine that commands should be added or updated in _apply.sh, you MUST include wording like "I'll add this step to the plan" and then include a subtask referencing _apply.sh in the ### Tasks list.`
}
s += `
- You MUST output a new/updated ### Tasks list
+ `
+
+ if params.ExecMode {
+ s += `
+ - If the ### Commands section indicates that commands should be added or updated in _apply.sh, you MUST also create a subtask referencing _apply.sh in the ### Tasks list
+ `
+ }
+
+ s += `
- You MUST NOT start implementing code
- You MUST follow planning phase format exactly