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
some fixes for token count/checkmark display during plan stream. some further refining of auto-continue prompts
Dane Schneider84e75fb36119
diff --git a/app/cli/stream_tui/view.go b/app/cli/stream_tui/view.goindex 23b42620..6e68d258 100644--- a/app/cli/stream_tui/view.go+++ b/app/cli/stream_tui/view.go@@ -82,11 +82,13 @@ func (m streamUIModel) doRenderBuild(outputStatic bool) string {lbl := "Building plan "bgColor := color.BgGreen+ built := falseif outputStatic {// log.Printf("m.finished: %v, len(m.finishedByPath): %d, len(m.tokensByPath): %d", m.finished, len(m.finishedByPath), len(m.tokensByPath))if m.finished || len(m.finishedByPath) == len(m.tokensByPath) {lbl = "Built plan "+ built = true} else if m.stopped || m.err != nil || m.apiErr != nil {lbl = "Build incomplete "bgColor = color.BgRed@@ -110,7 +112,7 @@ func (m streamUIModel) doRenderBuild(outputStatic bool) string {for _, filePath := range filePaths {tokens := m.tokensByPath[filePath]- finished := m.finished || m.finishedByPath[filePath]+ finished := m.finished || m.finishedByPath[filePath] || builtblock := fmt.Sprintf("📄 %s", filePath)if finished {diff --git a/app/server/model/plan/build_fix_stream.go b/app/server/model/plan/build_fix_stream.goindex 742bc92d..344758b0 100644--- a/app/server/model/plan/build_fix_stream.go+++ b/app/server/model/plan/build_fix_stream.go@@ -225,6 +225,17 @@ func (fileState *activeBuildStreamFileState) listenStreamFixChanges(stream *open}}+ buildInfo := &shared.BuildInfo{+ Path: filePath,+ NumTokens: 0,+ Finished: true,+ }+ activePlan.Stream(shared.StreamMessage{+ Type: shared.StreamMessageBuildInfo,+ BuildInfo: buildInfo,+ })+ time.Sleep(50 * time.Millisecond)+fileState.onFinishBuildFile(planFileResult, updated)return} else if len(delta.ToolCalls) == 0 {@@ -251,6 +262,24 @@ func (fileState *activeBuildStreamFileState) fixRetryOrAbort(err error) {} else {log.Printf("Aborting fix file '%s' due to error: %v\n", fileState.filePath, err)+ activePlan := GetActivePlan(fileState.plan.Id, fileState.branch)++ if activePlan == nil {+ log.Println("fixRetryOrAbort - Active plan not found")+ return+ }++ buildInfo := &shared.BuildInfo{+ Path: fileState.filePath,+ NumTokens: 0,+ Finished: true,+ }+ activePlan.Stream(shared.StreamMessage{+ Type: shared.StreamMessageBuildInfo,+ BuildInfo: buildInfo,+ })+ time.Sleep(50 * time.Millisecond)+fileState.onFinishBuildFile(nil, "")}}diff --git a/app/server/model/plan/build_stream_line_nums.go b/app/server/model/plan/build_stream_line_nums.goindex 1b7cfa7a..3897203a 100644--- a/app/server/model/plan/build_stream_line_nums.go+++ b/app/server/model/plan/build_stream_line_nums.go@@ -213,6 +213,7 @@ func (fileState *activeBuildStreamFileState) listenStreamChangesWithLineNums(strType: shared.StreamMessageBuildInfo,BuildInfo: buildInfo,})+ time.Sleep(50 * time.Millisecond)fileState.updated = updatedFilediff --git a/app/server/model/plan/build_verify.go b/app/server/model/plan/build_verify.goindex 06fc0e39..86dca00c 100644--- a/app/server/model/plan/build_verify.go+++ b/app/server/model/plan/build_verify.go@@ -45,7 +45,7 @@ func (fileState *activeBuildStreamFileState) verifyFileBuild() {verifyState.proposedChanges,)- log.Println("verify sysPrompt:\n", sysPrompt)+ // log.Println("verify sysPrompt:\n", sysPrompt)fileMessages := []openai.ChatCompletionMessage{{diff --git a/app/server/model/plan/build_verify_stream.go b/app/server/model/plan/build_verify_stream.goindex 049f934d..83d05350 100644--- a/app/server/model/plan/build_verify_stream.go+++ b/app/server/model/plan/build_verify_stream.go@@ -117,6 +117,9 @@ func (fileState *activeBuildStreamFileState) listenStreamVerifyOutput(stream *opBuildInfo: buildInfo,})log.Println("build verify - streamed.IsCorrect")++ time.Sleep(50 * time.Millisecond)+fileState.onFinishBuildFile(nil, "")} else {diff --git a/app/server/model/plan/exec_status.go b/app/server/model/plan/exec_status.goindex 9933d066..4baafad9 100644--- a/app/server/model/plan/exec_status.go+++ b/app/server/model/plan/exec_status.go@@ -121,7 +121,8 @@ func (state *activeTellStreamState) execStatusShouldContinue(message string, latvar strRes stringvar res struct {- Comments []struct {+ MessageFinishedSubtasks []string `json:"messageSubtasksFinished"`+ Comments []struct {Txt string `json:"txt"`IsTodoPlaceholder bool `json:"isTodoPlaceholder"`} `json:"comments"`diff --git a/app/server/model/plan/tell_stream.go b/app/server/model/plan/tell_stream.goindex 5c2f2117..7bb8e425 100644--- a/app/server/model/plan/tell_stream.go+++ b/app/server/model/plan/tell_stream.go@@ -297,6 +297,8 @@ func (state *activeTellStreamState) listenStream(stream *openai.ChatCompletionStlog.Printf("Won't continue plan. Build finished: %v\n", buildFinished)+ time.Sleep(50 * time.Millisecond)+if buildFinished {log.Println("Plan is finished")active.Stream(shared.StreamMessage{diff --git a/app/server/model/prompts/exec_status.go b/app/server/model/prompts/exec_status.goindex 94d3ec2b..b46f4f41 100644--- a/app/server/model/prompts/exec_status.go+++ b/app/server/model/prompts/exec_status.go@@ -19,12 +19,14 @@ If any new subtasks have been added to plan that haven't been implemented yet, eIf A1 1 has indicated that the plan is complete, but there are still subtasks remaining that have not been implemented, the plan should continue despite AI 1's statement that the plan is complete. The plan should only be considered complete if all tasks and subtasks have been fully implemented.+DO NOT only go by the latest summary when considering whether subtasks are complete. You MUST also consider the latest message from AI 1 and the previous message from AI 1 if it is provided. If the latest or previous message from AI 1 has new subtasks that have not been implemented, the plan should continue. If the latest or previous message from AI 1 has *finished* subtasks that are not marked as implemented in the summary, you MUST consider them as implemented.+If no subtasks are remaining to be implemented:- Assess whether AI 1 has concluded with a statement that indicates either the user needs to take specific actions before the plan can proceed, or that the plan can't automatically continue for any other reason. If so, the plan should not continue.- - If AI 1 has outlined a clear next step necessary to finish the plan but has not executed it, the plan should continue.+You *must* call the shouldAutoContinue function with a JSON object containing the keys 'messageSubtasksFinished', 'comments', 'reasoning', and 'shouldContinue'.-You *must* call the shouldAutoContinue function with a JSON object containing the keys 'comments', 'reasoning', and 'shouldContinue'.+The 'messageSubtasksFinished' key is an array of strings that represent subtasks that have been completed in the latest message OR the previous message (if included) from AI 1. If there are no subtasks that have been completed in the latest message, 'messageSubtasksFinished' must be an empty array. These MUST ONLY be subtasks that AI one has clearly stated are finished or done or implemented in either the latest or previous message. Do NOT list any subtasks from the summary in 'messageSubtasksFinished'. If there are no subtasks that have been completed in the latest message, 'messageSubtasksFinished' must be an empty array.The 'comments' key is an array of objects with two properties: 'txt' and 'isTodoPlaceholder'. 'txt' is the exact text of a code comment. 'isTodoPlaceholder' is a boolean that indicates whether the comment is a placeholder for a task that has not yet been implemented. This includes comments like "// Add logic here" or "// Implement the function", or "# Update the state" or " # Finish implementation" or any similar placeholder comments that describe tasks that still remain to be implemented. A todo placeholder does NOT have to exactly match any of the previous examples. Use your judgment to determine whether a comment is a todo placeholder.@@ -34,9 +36,13 @@ If any of the comments in the 'comments' array are todo placeholders, the plan MSet 'reasoning' to a string briefly and succinctly explaining your reasoning for why the plan should or should not continue, based on your instructions above.+Take into account both the latest message from AI 1, the previous message from AI 1 if it is provided, and the latest summary if it is provided. If a subtask is marked as completed in *either* the summary, the latest message, or the previous message from AI 1, it should be considered as implemented.++Between all of these sources, explain whether all subtasks have been implemented or whether there are still subtasks remaining that have not yet been completed.+If there are any todo placeholders in the 'comments' array, list them ALL in 'reasoning'.-If the plan should continue, also state what the immediate next step should be in 'reasoning'.+If the plan should continue, also state what the immediate next step should be in 'reasoning'. You MUST NOT state any subtasks that have been marked implemented in the summary or completed in the latest message or previous message from AI 1. You MUST only state what the next unimplemented subtask is and that should be done next.Set 'shouldContinue' to true if the plan should automatically continue based on your instructions above, or false otherwise.@@ -65,6 +71,12 @@ var ShouldAutoContinueFn = openai.FunctionDefinition{Parameters: &jsonschema.Definition{Type: jsonschema.Object,Properties: map[string]jsonschema.Definition{+ "messageFinishedSubtasks": {+ Type: jsonschema.Array,+ Items: &jsonschema.Definition{+ Type: jsonschema.String,+ },+ },"comments": {Type: jsonschema.Array,Items: &jsonschema.Definition{