fix(channels): dismiss tool feedback animation when turn ends via ResponseHandled

When a tool sets ResponseHandled=true (e.g., send_file), the turn ends
without producing a final assistant response. This meant no outbound
message triggered FinalizeToolFeedbackMessage, leaving the animation
goroutine running indefinitely — editing the Feishu card every 3 seconds
with "." / ".." suffixes long after the tool had finished.

Fix: call DismissToolFeedback at "Tool output satisfied delivery" so the
tracker is cleared and the animation goroutine is stopped immediately.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Guoguo 2026-04-29 05:08:29 -07:00
parent a36472b55f
commit fe42042c0c
3 changed files with 19 additions and 0 deletions

View file

@ -44,4 +44,9 @@ type ChannelManager interface {
// SendPlaceholder sends a placeholder message (e.g., for audio transcription). // SendPlaceholder sends a placeholder message (e.g., for audio transcription).
SendPlaceholder(ctx context.Context, channel, chatID string) bool SendPlaceholder(ctx context.Context, channel, chatID string) bool
// DismissToolFeedback clears any tracked tool feedback animation for the
// given channel/chat. Call this when a turn ends without a final response
// (e.g., ResponseHandled tools) to avoid orphaned animation goroutines.
DismissToolFeedback(ctx context.Context, channel, chatID string)
} }

View file

@ -704,6 +704,9 @@ toolLoop:
} }
ts.setPhase(TurnPhaseCompleted) ts.setPhase(TurnPhaseCompleted)
ts.setFinalContent("") ts.setFinalContent("")
if al.channelManager != nil && ts.channel != "" {
al.channelManager.DismissToolFeedback(ctx, ts.channel, ts.chatID)
}
logger.InfoCF("agent", "Tool output satisfied delivery; ending turn without follow-up LLM", logger.InfoCF("agent", "Tool output satisfied delivery; ending turn without follow-up LLM",
map[string]any{ map[string]any{
"agent_id": ts.agent.ID, "agent_id": ts.agent.ID,

View file

@ -192,6 +192,17 @@ func clearTrackedToolFeedbackMessage(
} }
} }
// DismissToolFeedback clears any tracked tool feedback animation for the
// given channel/chat. This is called when a turn ends without a final
// response (e.g., ResponseHandled tools) to stop orphaned animation goroutines.
func (m *Manager) DismissToolFeedback(ctx context.Context, channelName, chatID string) {
ch, ok := m.GetChannel(channelName)
if !ok {
return
}
dismissTrackedToolFeedbackMessage(ctx, ch, chatID, nil)
}
func prepareToolFeedbackMessageContent(ch Channel, content string) string { func prepareToolFeedbackMessageContent(ch Channel, content string) string {
prepared := strings.TrimSpace(content) prepared := strings.TrimSpace(content)
if prepared == "" { if prepared == "" {