Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
prompt updates + context now goes at the end
Dane Schneider65bc6a66acc9
diff --git a/app/server/model/plan/build_fix_stream.go b/app/server/model/plan/build_fix_stream.goindex 344758b0..0788874c 100644--- a/app/server/model/plan/build_fix_stream.go+++ b/app/server/model/plan/build_fix_stream.go@@ -122,7 +122,7 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *openif err == nil {log.Printf("listenStreamFixChanges - File %s: Parsed streamed replacements\n", filePath)- // spew.Dump(streamed)+ spew.Dump(streamed)sorted := []*shared.StreamedChangeWithLineNums{}diff --git a/app/server/model/plan/tell_exec.go b/app/server/model/plan/tell_exec.goindex c9ec9293..6e55a496 100644--- a/app/server/model/plan/tell_exec.go+++ b/app/server/model/plan/tell_exec.go@@ -162,7 +162,7 @@ func execTellPlan(return}- systemMessageText := prompts.SysCreate + modelContextText+ systemMessageText := prompts.SysCreatesystemMessage := openai.ChatCompletionMessage{Role: openai.ChatMessageRoleSystem,Content: systemMessageText,@@ -362,9 +362,18 @@ func execTellPlan(}log.Printf("\n\nMessages: %d\n", len(state.messages))- // for _, message := range state.messages {- // log.Printf("%s: %s\n", message.Role, message.Content)- // }++ if modelContextText != "" {+ // insert model context at second to last message+ state.messages = append(state.messages[:len(state.messages)-1], append([]openai.ChatCompletionMessage{{+ Role: openai.ChatMessageRoleSystem,+ Content: "# User-provided context:\n\n" + modelContextText,+ }}, state.messages[len(state.messages)-1:]...)...)+ }++ for _, message := range state.messages {+ log.Printf("%s: %s\n", message.Role, message.Content)+ }modelReq := openai.ChatCompletionRequest{Model: state.settings.ModelPack.Planner.BaseModelConfig.ModelName,diff --git a/app/server/model/prompts/build.go b/app/server/model/prompts/build.goindex 0d78159c..8dce241a 100644--- a/app/server/model/prompts/build.go+++ b/app/server/model/prompts/build.go@@ -164,7 +164,7 @@ In the 'problems' key, you MUST explain how you will strategically generate chanYou must consider whether you will apply partial changes or replace the entire file. If the original file is long, you MUST NOT replace the entire file with a single change. Instead, you should apply changes to specific sections of the file. If the original file is short and the changes are complex, you may consider replacing the entire file with a single change.-You must consider how you will avoid *incorrectly removing or overwriting code* from the original file. Explain whether any code from the original file needs to be merged with the proposed updates in order to avoid removing or overwriting code that should not be removed.+You must consider how you will avoid *incorrectly removing or overwriting code* from the original file. Explain whether any code from the original file needs to be merged with the proposed updates in order to avoid removing or overwriting code that should not be removed. It is ABSOLUTELY CRITICAL that no pre-existing code or functionality is removed or overwritten unless the plan explicitly intends for it to be removed or overwritten. New code and functionality introduced in the proposed updates MUST be *merged* with existing code and functionality in the original file. Explain how you will achieve this.You must consider how you will avoid including any references in the updated file if any are present in the proposed updates.diff --git a/app/server/model/prompts/create.go b/app/server/model/prompts/create.goindex a363478e..ef6ef979 100644--- a/app/server/model/prompts/create.go+++ b/app/server/model/prompts/create.go@@ -8,7 +8,7 @@ import (const SysCreate = Identity + ` A plan is a set of files with an attached context.` +- "# Your instructions:\n\n```\n" ++ "[YOUR INSTRUCTIONS:]" +`First, decide if the user has a task for you.@@ -192,6 +192,8 @@ const SysCreate = Identity + ` A plan is a set of files with an attached contextDO NOT summarize the state of the plan. Another AI will do that. Your job is to move the plan forward, not to summarize it. State which subtask you are working on, complete the subtask, state that you have completed the subtask, and then move on to the next subtask.+ Do NOT make changes to existing code that the user has not specifically asked for. Implement ONLY the exact changes the user has asked for. Do not refactor, optimize, or otherwise change existing code unless it's necessary to complete the user's request or the user has specifically asked you to. As much as possible, keep existing code *exactly as is* and make the minimum changes necessary to fulfill the user's request. Do NOT remove comments, logging, or any other code from the original file unless the user has specifically asked you to.+## Continuing the planNEVER repeat any part of your previous response. Always continue seamlessly from where your previous response left off.@@ -209,16 +211,16 @@ const SysCreate = Identity + ` A plan is a set of files with an attached contextIf the latest state of the context makes the current subtask you are working on redundant or unnecessary, say so, mark that subtask as done, and move on to the next subtask. Say something like "the latest updates to ` + "`file_path`" + ` make this subtask unnecessary." I'll mark it as done and move on to the next subtask." and then mark the subtask as done and move on to the next subtask.- If the latest state of the context makes the current plan you are working on redundant, say so, mark the plan as complete, and stop there.-- Otherwise, implement the subtask.+ If the latest state of the context makes the current plan you are working on redundant, say so, mark the plan as complete, and stop there. Otherwise, implement the subtask.++ Always work from the LATEST state of the user-provided context. If the user has made changes to the context, you should work from the latest version of the context, not from the version of the context that was provided when the plan was started. Earlier version of the context may have been used during the conversation, but you should always work from the *latest version* of the context when continuing the plan.## Responding to user questionsIf a plan is in progress and the user asks you a question, don't respond by continuing with the plan unless that is the clear intention of the question. Instead, respond in chat form and answer the question, then stop there.- ` +- "\n```\n\n" +- "# User-provided context:"++ [END OF YOUR INSTRUCTIONS]+ `var CreateSysMsgNumTokens, _ = shared.GetNumTokens(SysCreate)diff --git a/releases/server/versions/1.0.2.md b/releases/server/versions/1.0.2.mdindex 0edce3dc..424a9d3b 100644--- a/releases/server/versions/1.0.2.md+++ b/releases/server/versions/1.0.2.md@@ -1,5 +1,5 @@- Give notes added to context with `plandex load -n 'some note'` automatically generated names in `context ls` list.- Fixes for summarization and auto-continue issues that could Plandex to lose track of where it is in the plan and repeat tasks or do tasks out of order, especially when using `tell` and `continue` after the initial `tell`.- Improvements to the verification and auto-fix step. Plandex is now more likely to catch and fix placeholder references like "// ... existing code ..." as well as incorrect removal or overwriting of code.-- When a file is updated multiple times in a plan, Plandex is less likely to use an old version of the code from earlier in the conversation--it now uses the latest version much more reliably.+- After a context file is updated, Plandex is less likely to use an old version of the code from earlier in the conversation--it now uses the latest version much more reliably.- Increase wait times when receiving rate limit errors from OpenAI API (common with new OpenAI accounts that haven't spent $50).\ No newline at end of file