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)
|
route, agent, err := al.resolveMessageRoute(msg)
|
||||||
if err != nil || agent == nil {
|
if err != nil || agent == nil {
|
||||||
if err != 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)
|
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."
|
return true, "Command unavailable in current context."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1062,7 +1062,7 @@ func TestAgentLoop_Steering_BtwCommandBypassesQueuedTurn(t *testing.T) {
|
||||||
Channel: "test",
|
Channel: "test",
|
||||||
SenderID: "user1",
|
SenderID: "user1",
|
||||||
ChatID: "chat1",
|
ChatID: "chat1",
|
||||||
Content: "/btw 你说283928",
|
Content: "/btw what is the current progress?",
|
||||||
Peer: bus.Peer{
|
Peer: bus.Peer{
|
||||||
Kind: "direct",
|
Kind: "direct",
|
||||||
ID: "user1",
|
ID: "user1",
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,11 @@ func btwCommand() Definition {
|
||||||
return req.Reply(unavailableMsg)
|
return req.Reply(unavailableMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
question := strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(req.Text), nthToken(req.Text, 0)))
|
parts := strings.Fields(strings.TrimSpace(req.Text))
|
||||||
if question == "" {
|
if len(parts) < 2 {
|
||||||
return req.Reply("Usage: /btw <question>")
|
return req.Reply("Usage: /btw <question>")
|
||||||
}
|
}
|
||||||
|
question := strings.Join(parts[1:], " ")
|
||||||
|
|
||||||
answer, err := rt.AskSideQuestion(ctx, question)
|
answer, err := rt.AskSideQuestion(ctx, question)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue