feat(agent): update requeueInboundMessage to publish back to inbound bus and add corresponding tests

This commit is contained in:
Hoshina 2026-03-26 11:07:03 +08:00
parent 664e23e4fb
commit 70e8cf0725
2 changed files with 37 additions and 5 deletions

View file

@ -1393,11 +1393,7 @@ func (al *AgentLoop) requeueInboundMessage(msg bus.InboundMessage) error {
}
pubCtx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
return al.bus.PublishOutbound(pubCtx, bus.OutboundMessage{
Channel: msg.Channel,
ChatID: msg.ChatID,
Content: msg.Content,
})
return al.bus.PublishInbound(pubCtx, msg)
}
func (al *AgentLoop) processSystemMessage(

View file

@ -225,6 +225,42 @@ func TestProcessMessage_UseCommandLoadsRequestedSkill(t *testing.T) {
}
}
func TestRequeueInboundMessage_PublishesBackToInboundBus(t *testing.T) {
msgBus := bus.NewMessageBus()
al := &AgentLoop{bus: msgBus}
original := bus.InboundMessage{
Channel: "feishu",
SenderID: "feishu:user-1",
ChatID: "chat-1",
Content: "follow-up message",
MessageID: "msg-1",
}
if err := al.requeueInboundMessage(original); err != nil {
t.Fatalf("requeueInboundMessage() error = %v", err)
}
select {
case got := <-msgBus.InboundChan():
if got.Channel != original.Channel ||
got.SenderID != original.SenderID ||
got.ChatID != original.ChatID ||
got.Content != original.Content ||
got.MessageID != original.MessageID {
t.Fatalf("requeued message = %+v, want %+v", got, original)
}
case <-time.After(2 * time.Second):
t.Fatal("timeout waiting for requeued inbound message")
}
select {
case outbound := <-msgBus.OutboundChan():
t.Fatalf("unexpected outbound message after requeue: %+v", outbound)
default:
}
}
func TestHandleCommand_UseCommandRejectsUnknownSkill(t *testing.T) {
tmpDir := t.TempDir()
cfg := &config.Config{