Skip to content

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

Merge branch 'main' into litellm

Dane Schneider37b93ab7468b
diff --cc app/server/handlers/context_helper.go
index fb746b9a,38eab4e1..cb15dfbc
--- a/app/server/handlers/context_helper.go
+++ b/app/server/handlers/context_helper.go
@@@ -136,7 -135,15 +138,15 @@@ func loadContexts
num++
go func(context *shared.LoadContextParams) {
+ defer func() {
+ if r := recover(); r != nil {
+ log.Printf("panic in GenPipedDataName: %v\n%s", r, debug.Stack())
+ errCh <- fmt.Errorf("panic in GenPipedDataName: %v\n%s", r, debug.Stack())
+ runtime.Goexit() // don't allow outer function to continue and double-send to channel
+ }
+ }()
+
- name, err := model.GenPipedDataName(r.Context(), auth, plan, settings, clients, context.Body, context.SessionId)
+ name, err := model.GenPipedDataName(r.Context(), auth, plan, settings, clients, authVars, context.Body, context.SessionId)
if err != nil {
errCh <- fmt.Errorf("error generating name for piped data: %v", err)
@@@ -150,7 -157,15 +160,15 @@@
num++
go func(context *shared.LoadContextParams) {
+ defer func() {
+ if r := recover(); r != nil {
+ log.Printf("panic in GenNoteName: %v\n%s", r, debug.Stack())
+ errCh <- fmt.Errorf("panic in GenNoteName: %v\n%s", r, debug.Stack())
+ runtime.Goexit() // don't allow outer function to continue and double-send to channel
+ }
+ }()
+
- name, err := model.GenNoteName(r.Context(), auth, plan, settings, clients, context.Body, context.SessionId)
+ name, err := model.GenNoteName(r.Context(), auth, plan, settings, clients, authVars, context.Body, context.SessionId)
if err != nil {
errCh <- fmt.Errorf("error generating name for note: %v", err)
diff --cc app/server/model/plan/exec_status.go
index 2f7003f2,f222e229..a09719b2
--- a/app/server/model/plan/exec_status.go
+++ b/app/server/model/plan/exec_status.go
@@@ -32,71 -32,75 +32,77 @@@ func (state *activeTellStreamState) exe
plan := state.plan
settings := state.settings
clients := state.clients
+ authVars := state.authVars
config := settings.ModelPack.ExecStatus
+ baseModelConfig := config.GetBaseModelConfig(authVars)
+ currentSubtask := state.currentSubtask
+
+ if currentSubtask == nil {
+ log.Printf("[ExecStatus] No current subtask")
+ return execStatusShouldContinueResult{
+ subtaskFinished: true,
+ }, nil
+ }
// Check subtask completion
- if state.currentSubtask != nil {
- completionMarker := fmt.Sprintf("**%s** has been completed", state.currentSubtask.Title)
- log.Printf("[ExecStatus] Checking for subtask completion marker: %q", completionMarker)
- log.Printf("[ExecStatus] Current subtask: %q", state.currentSubtask.Title)
-
- if strings.Contains(currentMessage, completionMarker) {
- log.Printf("[ExecStatus] ✓ Subtask completion marker found")
- return execStatusShouldContinueResult{
- subtaskFinished: true,
- }, nil
-
- // NOTE: tried using an LLM to verify "suspicious" subtask completions, but in practice led to too many extra LLM calls and disagreement cycles between agent roles (it's finished. no it's note! etc.)
- // now just going back to trusting the completion marker... basically it's better to err on the side of marking tasks done.
-
- // var potentialProblem bool
-
- // if len(state.chunkProcessor.replyOperations) == 0 {
- // log.Printf("[ExecStatus] ✗ Subtask completion marker found, but there are no operations to execute")
- // potentialProblem = true
- // } else {
- // wroteToPaths := map[string]bool{}
- // for _, op := range state.chunkProcessor.replyOperations {
- // if op.Type == shared.OperationTypeFile {
- // wroteToPaths[op.Path] = true
- // }
- // }
-
- // for _, path := range state.currentSubtask.UsesFiles {
- // if !wroteToPaths[path] {
- // log.Printf("[ExecStatus] ✗ Subtask completion marker found, but the operations did not write to the file %q from the 'Uses' list", path)
- // potentialProblem = true
- // break
- // }
- // }
- // }
-
- // if !potentialProblem {
- // log.Printf("[ExecStatus] ✓ Subtask completion marker found and no potential problem - will mark as completed")
-
- // return execStatusShouldContinueResult{
- // subtaskFinished: true,
- // }, nil
- // } else if state.currentSubtask.NumTries >= 1 {
- // log.Printf("[ExecStatus] ✓ Subtask completion marker found, but the operations are questionable -- marking it done anyway since it's the second try and we can't risk an infinite loop")
-
- // return execStatusShouldContinueResult{
- // subtaskFinished: true,
- // }, nil
- // } else {
- // log.Printf("[ExecStatus] ✗ Subtask completion marker found, but the operations are questionable -- will verify with LLM call")
- // }
- } else {
- log.Printf("[ExecStatus] ✗ No subtask completion marker found in message")
- }
+ completionMarker := fmt.Sprintf("**%s** has been completed", currentSubtask.Title)
+ log.Printf("[ExecStatus] Checking for subtask completion marker: %q", completionMarker)
+ log.Printf("[ExecStatus] Current subtask: %q", currentSubtask.Title)
- log.Println("[ExecStatus] Current subtasks state:")
- for i, task := range state.subtasks {
- log.Printf("[ExecStatus] Task %d: %q (finished=%v)", i+1, task.Title, task.IsFinished)
- }
+ if strings.Contains(currentMessage, completionMarker) {
+ log.Printf("[ExecStatus] ✓ Subtask completion marker found")
+ return execStatusShouldContinueResult{
+ subtaskFinished: true,
+ }, nil
+
+ // NOTE: tried using an LLM to verify "suspicious" subtask completions, but in practice led to too many extra LLM calls and disagreement cycles between agent roles (it's finished. no it's note! etc.)
+ // now just going back to trusting the completion marker... basically it's better to err on the side of marking tasks done.
+
+ // var potentialProblem bool
+
+ // if len(state.chunkProcessor.replyOperations) == 0 {
+ // log.Printf("[ExecStatus] ✗ Subtask completion marker found, but there are no operations to execute")
+ // potentialProblem = true
+ // } else {
+ // wroteToPaths := map[string]bool{}
+ // for _, op := range state.chunkProcessor.replyOperations {
+ // if op.Type == shared.OperationTypeFile {
+ // wroteToPaths[op.Path] = true
+ // }
+ // }
+
+ // for _, path := range currentSubtask.UsesFiles {
+ // if !wroteToPaths[path] {
+ // log.Printf("[ExecStatus] ✗ Subtask completion marker found, but the operations did not write to the file %q from the 'Uses' list", path)
+ // potentialProblem = true
+ // break
+ // }
+ // }
+ // }
+
+ // if !potentialProblem {
+ // log.Printf("[ExecStatus] ✓ Subtask completion marker found and no potential problem - will mark as completed")
+
+ // return execStatusShouldContinueResult{
+ // subtaskFinished: true,
+ // }, nil
+ // } else if currentSubtask.NumTries >= 1 {
+ // log.Printf("[ExecStatus] ✓ Subtask completion marker found, but the operations are questionable -- marking it done anyway since it's the second try and we can't risk an infinite loop")
+
+ // return execStatusShouldContinueResult{
+ // subtaskFinished: true,
+ // }, nil
+ // } else {
+ // log.Printf("[ExecStatus] ✗ Subtask completion marker found, but the operations are questionable -- will verify with LLM call")
+ // }
+ } else {
+ log.Printf("[ExecStatus] ✗ No subtask completion marker found in message")
+ }
+
+ log.Println("[ExecStatus] Current subtasks state:")
+ for i, task := range state.subtasks {
+ log.Printf("[ExecStatus] Task %d: %q (finished=%v)", i+1, task.Title, task.IsFinished)
}
log.Println("Checking if plan should continue based on exec status")
diff --cc app/server/model/plan/tell_stream_finish.go
index 2325d401,08e77ae7..ea52ee93
--- a/app/server/model/plan/tell_stream_finish.go
+++ b/app/server/model/plan/tell_stream_finish.go
@@@ -113,7 -107,18 +114,19 @@@ func (state *activeTellStreamState) han
log.Println("summarizing convo in background")
// summarize in the background
go func() {
++
+ defer func() {
+ if r := recover(); r != nil {
+ log.Printf("panic in summarizeConvo: %v\n%s", r, debug.Stack())
+ active.StreamDoneCh <- &shared.ApiError{
+ Type: shared.ApiErrorTypeOther,
+ Status: http.StatusInternalServerError,
+ Msg: fmt.Sprintf("Error summarizing convo: %v", r),
+ }
+ }
+ }()
+
- err := summarizeConvo(clients, settings.ModelPack.PlanSummary, summarizeConvoParams{
+ err := summarizeConvo(clients, authVars, settings.ModelPack.PlanSummary, summarizeConvoParams{
auth: auth,
plan: plan,
branch: branch,
diff --cc app/server/model/plan/tell_stream_usage.go
index f5b99bd8,49c1fc7a..e24f1f66
--- a/app/server/model/plan/tell_stream_usage.go
+++ b/app/server/model/plan/tell_stream_usage.go
@@@ -24,9 -27,15 +27,16 @@@ func (state *activeTellStreamState) han
sessionId := state.activePlan.SessionId
modelConfig := state.modelConfig
+ baseModelConfig := modelConfig.GetBaseModelConfig(state.authVars)
go func() {
+ defer func() {
+ if r := recover(); r != nil {
+ log.Printf("panic in handleUsageChunk: %v\n%s", r, debug.Stack())
+ go notify.NotifyErr(notify.SeverityError, fmt.Errorf("panic in handleUsageChunk: %v\n%s", r, debug.Stack()))
+ }
+ }()
+
_, apiErr := hooks.ExecHook(hooks.DidSendModelRequest, hooks.HookParams{
Auth: auth,
Plan: plan,
@@@ -80,9 -88,15 +90,16 @@@ func (state *activeTellStreamState) exe
}
modelConfig := state.modelConfig
+ baseModelConfig := modelConfig.GetBaseModelConfig(state.authVars)
go func() {
+ defer func() {
+ if r := recover(); r != nil {
+ log.Printf("panic in execHookOnStop: %v\n%s", r, debug.Stack())
+ go notify.NotifyErr(notify.SeverityError, fmt.Errorf("panic in execHookOnStop: %v\n%s", r, debug.Stack()))
+ }
+ }()
+
_, apiErr := hooks.ExecHook(hooks.DidSendModelRequest, hooks.HookParams{
Auth: auth,
Plan: plan,