From 52ef16a9c0bd6864540946e07a7649c6fd4a5587 Mon Sep 17 00:00:00 2001 From: lxowalle Date: Tue, 14 Apr 2026 11:49:03 +0800 Subject: [PATCH] fix(agent): improve /btw command implementation --- pkg/agent/loop.go | 2 ++ pkg/agent/steering_test.go | 2 +- pkg/commands/cmd_btw.go | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index e1abbc6c7..b97c59848 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -3793,8 +3793,10 @@ func (al *AgentLoop) tryHandlePriorityCommand(ctx context.Context, msg bus.Inbou route, agent, err := al.resolveMessageRoute(msg) if err != nil || agent == nil { if err != nil { + logger.ErrorCF("agent", fmt.Sprintf("Error resolving route for /btw: %v", err), nil) return true, fmt.Sprintf("Error processing message: %v", err) } + logger.WarnCF("agent", "/btw command unavailable: no agent resolved", nil) return true, "Command unavailable in current context." } diff --git a/pkg/agent/steering_test.go b/pkg/agent/steering_test.go index 4ca36eef3..4d6522c63 100644 --- a/pkg/agent/steering_test.go +++ b/pkg/agent/steering_test.go @@ -1062,7 +1062,7 @@ func TestAgentLoop_Steering_BtwCommandBypassesQueuedTurn(t *testing.T) { Channel: "test", SenderID: "user1", ChatID: "chat1", - Content: "/btw 你说283928", + Content: "/btw what is the current progress?", Peer: bus.Peer{ Kind: "direct", ID: "user1", diff --git a/pkg/commands/cmd_btw.go b/pkg/commands/cmd_btw.go index db9e729d6..f35ee9bcf 100644 --- a/pkg/commands/cmd_btw.go +++ b/pkg/commands/cmd_btw.go @@ -17,10 +17,11 @@ func btwCommand() Definition { return req.Reply(unavailableMsg) } - question := strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(req.Text), nthToken(req.Text, 0))) - if question == "" { + parts := strings.Fields(strings.TrimSpace(req.Text)) + if len(parts) < 2 { return req.Reply("Usage: /btw ") } + question := strings.Join(parts[1:], " ") answer, err := rt.AskSideQuestion(ctx, question) if err != nil {