fix(agent): improve /btw command implementation
This commit is contained in:
parent
2afda7e0ec
commit
52ef16a9c0
3 changed files with 6 additions and 3 deletions
|
|
@ -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."
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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>")
|
||||
}
|
||||
question := strings.Join(parts[1:], " ")
|
||||
|
||||
answer, err := rt.AskSideQuestion(ctx, question)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue