Skip to content

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

add error handling for stream error

Dane Schneider476be4615aac
diff --git a/app/cli/stream_tui/update.go b/app/cli/stream_tui/update.go
index 40fb2709..86334a55 100644
--- a/app/cli/stream_tui/update.go
+++ b/app/cli/stream_tui/update.go
@@ -334,8 +334,8 @@ func (m *streamUIModel) streamUpdate(msg *shared.StreamMessage, deferUIUpdate bo
return m.checkMissingFile(msg)
case shared.StreamMessageReply:
- log.Println("Stream message reply:")
- log.Println(spew.Sdump(msg))
+ // log.Println("Stream message reply:")
+ // log.Println(spew.Sdump(msg))
// ignore empty reply messages
if msg.ReplyChunk == "" {
diff --git a/app/server/model/plan/tell_context.go b/app/server/model/plan/tell_context.go
index 76a9b1ac..4ea5f23e 100644
--- a/app/server/model/plan/tell_context.go
+++ b/app/server/model/plan/tell_context.go
@@ -154,6 +154,8 @@ func (state *activeTellStreamState) checkAutoLoadContext() []string {
return nil
}
+ log.Printf("%d existing contexts by path\n", len(contextsByPath))
+
// pick out all potential file paths within backticks
matches := pathRegex.FindAllStringSubmatch(activePlan.CurrentReplyContent, -1)
diff --git a/app/server/model/plan/tell_stream_main.go b/app/server/model/plan/tell_stream_main.go
index 453e7681..a659d571 100644
--- a/app/server/model/plan/tell_stream_main.go
+++ b/app/server/model/plan/tell_stream_main.go
@@ -87,6 +87,13 @@ mainLoop:
log.Printf("Tell: error receiving stream chunk: %v\n", err)
state.execHookOnStop(true)
+
+ state.onError(onErrorParams{
+ streamErr: fmt.Errorf("error receiving stream chunk: %v", err),
+ storeDesc: true,
+ canRetry: true,
+ })
+ // here we want to return no matter what -- state.onError will decide whether to retry or not
return
}
diff --git a/app/server/types/active_plan.go b/app/server/types/active_plan.go
index 3a63722a..b879cdd9 100644
--- a/app/server/types/active_plan.go
+++ b/app/server/types/active_plan.go
@@ -182,7 +182,7 @@ func (ap *ActivePlan) FlushStreamBuffer() {
}
}
-const verboseStreamLogging = true
+const verboseStreamLogging = false
func (ap *ActivePlan) Stream(msg shared.StreamMessage) {
if verboseStreamLogging {