From 6ed6e2d076b98b12f764bdc3a5595f4d902d7932 Mon Sep 17 00:00:00 2001 From: jrussellsmyth Date: Wed, 4 Mar 2026 04:01:28 +0000 Subject: [PATCH] fix(agent): reset message tool sentInRound before handleCommand to unblock typing indicator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When handleCommand handles a command it returns early before SetContext is called on the message tool. If the previous LLM round used the message tool, sentInRound stays true. The Run loop's alreadySent check then silently drops the command response — PublishOutbound is never called, preSend never runs, and the typing indicator is never cancelled. Fix: reset the default agent's message tool context at the start of processMessage, before any early-return path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- pkg/agent/loop.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index b803187b1..11150eaa2 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -450,6 +450,18 @@ func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage) return al.processSystemMessage(ctx, msg) } + // Reset message-tool sentInRound before any early-return paths (including + // handleCommand) so that a stale true from the previous LLM round never + // causes the command response to be silently dropped in the Run loop's + // alreadySent check (which would leave the typing indicator stuck on). + if defaultAgent := al.registry.GetDefaultAgent(); defaultAgent != nil { + if tool, ok := defaultAgent.Tools.Get("message"); ok { + if mt, ok := tool.(tools.ContextualTool); ok { + mt.SetContext(msg.Channel, msg.ChatID) + } + } + } + // Check for commands if response, handled := al.handleCommand(ctx, msg); handled { return response, nil