File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -576,7 +576,17 @@ func formatToolWarning(a *agent.Agent, warnings []string) string {
576576 return strings .TrimSuffix (builder .String (), "\n " )
577577}
578578
579- // chanSend wraps a channel as a func(Event) for use with emitAgentWarnings.
579+ // chanSend wraps a channel as a func(Event) for use with emitAgentWarnings
580+ // and RAG event forwarding. The send is non-blocking: if the channel is full
581+ // or closed, the event is silently dropped. This prevents a panic when a
582+ // long-lived goroutine (e.g. RAG file watcher) tries to forward an event
583+ // after the per-message events channel has been closed.
580584func chanSend (ch chan Event ) func (Event ) {
581- return func (e Event ) { ch <- e }
585+ return func (e Event ) {
586+ defer func () { recover () }() //nolint:errcheck // swallow send-on-closed-channel panic
587+ select {
588+ case ch <- e :
589+ default :
590+ }
591+ }
582592}
You can’t perform that action at this time.
0 commit comments