fix(agent): reset message tool sentInRound before handleCommand to unblock typing indicator

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>
This commit is contained in:
jrussellsmyth 2026-03-04 04:01:28 +00:00
parent bea238c337
commit 6ed6e2d076

View file

@ -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