Skip to content

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

various model/prompt improvements and fixes

Dane Schneider85b08f3af680
diff --git a/app/cli/stream_tui/update.go b/app/cli/stream_tui/update.go
index aec6b186..756ca809 100644
--- a/app/cli/stream_tui/update.go
+++ b/app/cli/stream_tui/update.go
@@ -62,8 +62,8 @@ func (m streamUIModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if apiErr != nil {
log.Println("stop plan api error:", apiErr)
m.apiErr = apiErr
- return &m, nil
}
+ return m, tea.Quit
case bubbleKey.Matches(msg, m.keymap.scrollDown) && !m.promptingMissingFile:
m.scrollDown()
diff --git a/app/server/db/result_helpers.go b/app/server/db/result_helpers.go
index 93d5eae8..992bd97c 100644
--- a/app/server/db/result_helpers.go
+++ b/app/server/db/result_helpers.go
@@ -109,6 +109,8 @@ func GetCurrentPlanState(params CurrentPlanStateParams) (*shared.CurrentPlanStat
return
}
contexts = res
+
+ log.Println("Got contexts:", len(contexts))
} else {
contexts = params.Contexts
}
@@ -144,11 +146,11 @@ func GetCurrentPlanState(params CurrentPlanStateParams) (*shared.CurrentPlanStat
pendingContextsByPath := map[string]*shared.Context{}
for path, context := range contextsByPath {
- if pendingResultPaths[path] {
- pendingContextsByPath[path] = context.ToApi()
- }
+ pendingContextsByPath[path] = context.ToApi()
}
+ log.Println("Pending contexts by path:", len(pendingContextsByPath))
+
planState := &shared.CurrentPlanState{
PlanResult: planResult,
ConvoMessageDescriptions: convoMessageDescriptions,
diff --git a/app/server/model/plan/stop.go b/app/server/model/plan/stop.go
index 4f511bc1..b627496c 100644
--- a/app/server/model/plan/stop.go
+++ b/app/server/model/plan/stop.go
@@ -17,6 +17,13 @@ func Stop(planId, branch, currentUserId, currentOrgId string) error {
active.SummaryCancelFn()
active.CancelFn()
+ // rollback repo in case there are uncommitted builds
+ err := db.GitClearUncommittedChanges(currentOrgId, planId)
+
+ if err != nil {
+ return fmt.Errorf("error clearing uncommitted changes: %v", err)
+ }
+
if !active.BuildOnly && !active.RepliesFinished {
num := active.MessageNum + 1
diff --git a/app/server/model/prompts/build.go b/app/server/model/prompts/build.go
index f69b3f62..6b067afe 100644
--- a/app/server/model/prompts/build.go
+++ b/app/server/model/prompts/build.go
@@ -56,18 +56,21 @@ var listChangesPrompt = `
'summary' examples:
- 'Update loop that aggregates the results to iterate 10 times instead of 5 and log the value of someVar.'
- - 'Change the value of someVar to 10.'
- 'Update the Org model to include StripeCustomerId and StripeSubscriptionId fields.'
- 'Add function ExecQuery to execute a query.'
The 'section' property is a description of what section of code from the original file will be replaced.
- Refer to sections of code using line numbers, how the section begins, and how the section ends. It must be extremely clear which line(s) of code from the original file will be replaced.
+ Refer to sections of code with how the section begins and how the section ends. It must be extremely clear which line(s) of code from the original file will be replaced. Include at LEAST 3-5 lines each for describing where the code begins and ends and more if the exact location of where the section begins or ends is ambiguous with only 3-5 lines. Never describe a section as beginning or ending with only braces, brackets, parentheses, or newlines. Include as many lines as necessary to be sure that the section start and end locations include some code that does something. Even if you have to output a large number of lines to follow this rule, do so.
+
+ Sections of code begin and end with *entire* lines. Never begin or end a section in the middle of a line.
+
+ Abbreviate long lines of code with '...'. Include as many characters/words as needed to clearly disambiguate a line and no more.
'section' examples:
---
- Begins line 10 of the original file with 'for i := 0; i < 10; i++ {...'
- Ends on line 15 of the original file with '}'
+ Begins: 'for i := 0; i < 10; i++ {...'
+ Ends: ' }\n }\n}'
---
The 'old' property is an object with two properties: 'startLine' and 'endLine'.
@@ -76,22 +79,24 @@ var listChangesPrompt = `
The 'new' property is a string that represents the new code that will replace the old code. The new code must be valid and consistent with the intention of the plan. If the the proposed update is to remove code, the 'new' property should be an empty string.
- If the proposed update includes references to the original code in comments like "// rest of the function..." or "# existing init code...", or "// rest of the main function..." or "// rest of your function..." or any other reference to the original code, you *MUST* ensure that the comment making the reference is *NOT* included in the 'new' property. If the reference comment is included in the 'new' property the resulting code obviously won't work, so NEVER include the reference comment in the 'new' property. Instead include the actual code that the reference is pointing to so that the change results in the exact code that is intended.
+ If the proposed update includes references to the original code in comments like "// rest of the function..." or "# existing init code...", or "// rest of the main function..." or "// rest of your function..." or **any other reference to the original code,** you *MUST* ensure that the comment making the reference is *NOT* included in the 'new' property. Instead, include the **exact code** from the original file that the comment is referencing. Do not be overly strict in identifying references. If there is a comment that seems like it could plausibly be a reference and there is code in the original file that could plausibly be the code being referenced, then treat that as a reference and handle it accordingly by including the code from the original file in the 'new' property instead of the comment. YOU MUST NOT MISS ANY REFERENCES.
Example function call with all keys:
---
listChanges([{
- summary: "Insert function ExecQuery after GetResults function.",
- section' "Begins line 10 of the original file with 'for i := 0; i < 10; i++ {...'\nEnds on line 15 of the original file with '}'",
+ summary: "Insert function ExecQuery after GetResults function in loop body.",
+ section' "Begins: 'for i := 0; i < 10; i++ {...'\nEnds with ' }\n }\n}'",
old: {
startLine: 5,
- endLine: 5,
+ endLine: 10,
},
- new: "execQuery()\nreturn",
+ new: " execQuery()\n }\n }\n}",
}])
---
Apply changes intelligently in order to avoid syntax errors, breaking code, or removing code from the original file that should not be removed. Consider the reason behind the update and make sure the result is consistent with the intention of the plan.
+
+ Pay EXTREMELY close attention to opening and closing brackets, parentheses, and braces. Never leave them unbalanced when the changes are applied.
[END YOUR INSTRUCTIONS]
`
diff --git a/app/server/model/prompts/create.go b/app/server/model/prompts/create.go
index d5ec1bbc..03e10639 100644
--- a/app/server/model/prompts/create.go
+++ b/app/server/model/prompts/create.go
@@ -27,9 +27,9 @@ const SysCreate = Identity + ` A plan is a set of files with an attached context
- src/main.rs:
- lib/term.go:
- main.py:
- ***File paths should always come *before* the opening triple backticks of a code block. They should *not* be included in the code block itself.
- ***File paths should appear *immediately* before the opening triple backticks of a code block. There should be *no other lines* between the file path and the code block. Any explanations should come either *before the file path or after the code block.*
- ***You *must not* include any other text in a code block label apart from the initial '- ' and the file path. DO NOT use a label like 'File path: src/main.rs' or 'src/main.rs: (Create this file)'. Instead use 'src/main.rs:'. DO NOT include any explanatory text in the code block label like 'src/main.rs: (Add a new function)'. Instead, include any necessary explanations either before the file path or after the code block.
+ ***File paths MUST ALWAYS come *IMMEDIATELY before* the opening triple backticks of a code block. They should *not* be included in the code block itself.
+ ***File paths MUST ALWAYS appear *IMMEDIATELY* before the opening triple backticks of a code block. There MUST NEVER be *any other lines* between the file path and the the opening triple backticks. Any explanations should come either *before the file path or *after* the code block is closed by closing triple backticks.*
+ ***You *must not* include any other text in a code block label apart from the initial '- ' and the file path. DO NOT UNDER ANY CIRCUMSTANCES use a label like 'File path: src/main.rs' or 'src/main.rs: (Create this file)' or 'File to Create: src/main.rs' or 'File to Update: src/main.rs'. Instead use JUST 'src/main.rs:'. DO NOT include any explanatory text in the code block label like 'src/main.rs: (Add a new function)'. Instead, include any necessary explanations either before the file path or after the code block. You MUST ALWAYS WITH NO EXCEPTIONS use the exact format described here for file paths in code blocks.
b. If not:
- Explicitly say "Let's break up this task."
- Divide the task into smaller subtasks and list them in a numbered list. Stop there.
@@ -100,9 +100,15 @@ const SysCreate = Identity + ` A plan is a set of files with an attached context
- Don't consider the user verifying or testing the code as a next step. If all that's left is for the user to verify or test the code, consider the plan complete.
- ## Rules for responses
+ ## EXTREMELY IMPORTANT Rules for responses
- You *must never respond with just a single paragraph.* Every response should include at least a few paragraphs that try to move a plan forward. You *especially must never* reply with just a single paragraph that begins with "Next," or "The plan cannot be continued.". You must also **never reply with just a single paragraph that contains only "All tasks have been completed."**.
+ You *must never respond with just a single paragraph.* Every response should include at least a few paragraphs that try to move a plan forward. You *especially must never* reply with just a single paragraph that begins with "Next," or "The plan cannot be continued.".
+
+ You MUST NEVER **reply with just a single paragraph that contains only "All tasks have been completed."**.
+
+ You MUST NEVER begin any response with "The plan cannot be continued." or "All tasks have been completed.".
+
+ Every response must start by considering the previous responses and latest context and then attempt to move the plan forward.
If any paragraph begins with "Next,", it *must never* be followed by a paragraph containing "All tasks have been completed." or "The plan cannot be continued." *Only* if the task described in the "Next," paragraph has *BEEN COMPLETED* can you ever follow it with "All tasks have been completed.".
diff --git a/app/server/types/reply.go b/app/server/types/reply.go
index 00ffd870..e6123e17 100644
--- a/app/server/types/reply.go
+++ b/app/server/types/reply.go
@@ -135,7 +135,7 @@ func (r *ReplyParser) AddChunk(chunk string, addToTotal bool) {
r.maybeFilePath = ""
r.currentFileLines = []string{}
- r.fileDescriptions = append(r.fileDescriptions, strings.Join(r.currentDescriptionLines[0:len(r.currentDescriptionLines)-2], "\n"))
+ r.fileDescriptions = append(r.fileDescriptions, strings.Join(r.currentDescriptionLines[0:len(r.currentDescriptionLines)-4], "\n"))
r.currentDescriptionLines = []string{""}
r.currentDescriptionLineIdx = 0
diff --git a/app/shared/ai_models.go b/app/shared/ai_models.go
index 3f687a67..0019b038 100644
--- a/app/shared/ai_models.go
+++ b/app/shared/ai_models.go
@@ -110,8 +110,8 @@ func init() {
ModelRoleConfig: ModelRoleConfig{
Role: ModelRolePlanner,
BaseModelConfig: AvailableModelsByName[openai.GPT4TurboPreview],
- Temperature: 0.6,
- TopP: 0.7,
+ Temperature: 0.4,
+ TopP: 0.4,
},
PlannerModelConfig: PlannerModelConfigByName[openai.GPT4TurboPreview],
},
@@ -119,14 +119,14 @@ func init() {
Role: ModelRolePlanSummary,
BaseModelConfig: AvailableModelsByName[openai.GPT4TurboPreview],
Temperature: 0.3,
- TopP: 0.5,
+ TopP: 0.3,
},
Builder: TaskRoleConfig{
ModelRoleConfig: ModelRoleConfig{
Role: ModelRoleBuilder,
BaseModelConfig: AvailableModelsByName[openai.GPT4TurboPreview],
- Temperature: 0.3,
- TopP: 0.1,
+ Temperature: 0.2,
+ TopP: 0.2,
},
TaskModelConfig: TaskModelConfigByName[openai.GPT4TurboPreview],
},
@@ -134,7 +134,7 @@ func init() {
ModelRoleConfig: ModelRoleConfig{
Role: ModelRoleName,
BaseModelConfig: AvailableModelsByName[openai.GPT3Dot5Turbo],
- Temperature: 1.0,
+ Temperature: 0.8,
TopP: 0.5,
},
TaskModelConfig: TaskModelConfigByName[openai.GPT3Dot5Turbo],
@@ -143,7 +143,7 @@ func init() {
ModelRoleConfig: ModelRoleConfig{
Role: ModelRoleCommitMsg,
BaseModelConfig: AvailableModelsByName[openai.GPT3Dot5Turbo],
- Temperature: 1.0,
+ Temperature: 0.8,
TopP: 0.5,
},
TaskModelConfig: TaskModelConfigByName[openai.GPT3Dot5Turbo],
diff --git a/app/shared/plan_result_replacements.go b/app/shared/plan_result_replacements.go
index 711f93ea..d9b2c4ad 100644
--- a/app/shared/plan_result_replacements.go
+++ b/app/shared/plan_result_replacements.go
@@ -78,6 +78,11 @@ func (planState *CurrentPlanState) GetFilesBeforeReplacement(
continue
} else if updated == "" {
context := planState.ContextsByPath[path]
+
+ if context == nil {
+ log.Printf("No context for path: %s\n", path)
+ }
+
updated = context.Body
shas[path] = context.Sha
}