feat(agent): update requeueInboundMessage to publish back to inbound bus and add corresponding tests
This commit is contained in:
parent
664e23e4fb
commit
70e8cf0725
2 changed files with 37 additions and 5 deletions
|
|
@ -1393,11 +1393,7 @@ func (al *AgentLoop) requeueInboundMessage(msg bus.InboundMessage) error {
|
||||||
}
|
}
|
||||||
pubCtx, cancel := context.WithTimeout(context.Background(), time.Second)
|
pubCtx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
return al.bus.PublishOutbound(pubCtx, bus.OutboundMessage{
|
return al.bus.PublishInbound(pubCtx, msg)
|
||||||
Channel: msg.Channel,
|
|
||||||
ChatID: msg.ChatID,
|
|
||||||
Content: msg.Content,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (al *AgentLoop) processSystemMessage(
|
func (al *AgentLoop) processSystemMessage(
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
func TestHandleCommand_UseCommandRejectsUnknownSkill(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
cfg := &config.Config{
|
cfg := &config.Config{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue