Merge fix/cron-peer-routing: route cron jobs to correct agent and publish response to channel
This commit is contained in:
commit
42abd78165
2 changed files with 15 additions and 2 deletions
|
|
@ -679,6 +679,12 @@ func (al *AgentLoop) ProcessDirectWithChannel(
|
|||
Content: content,
|
||||
SessionKey: sessionKey,
|
||||
}
|
||||
// Set peer so channel-based bindings (e.g. a specific Slack channel mapped
|
||||
// to a named agent) are matched by the route resolver, exactly as they are
|
||||
// for live inbound messages.
|
||||
if chatID != "" && chatID != "direct" {
|
||||
msg.Peer = bus.Peer{Kind: "channel", ID: chatID}
|
||||
}
|
||||
|
||||
return al.processMessage(ctx, msg)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,7 +341,14 @@ func (t *CronTool) ExecuteJob(ctx context.Context, job *cron.CronJob) string {
|
|||
return fmt.Sprintf("Error: %v", err)
|
||||
}
|
||||
|
||||
// Response is automatically sent via MessageBus by AgentLoop
|
||||
_ = response // Will be sent by AgentLoop
|
||||
if response != "" {
|
||||
pubCtx, pubCancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer pubCancel()
|
||||
t.msgBus.PublishOutbound(pubCtx, bus.OutboundMessage{
|
||||
Channel: channel,
|
||||
ChatID: chatID,
|
||||
Content: response,
|
||||
})
|
||||
}
|
||||
return "ok"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue