fix(cron): publish agent response for deliver=false cron tasks

ProcessDirectWithChannel returns the LLM response but does not publish
it via MessageBus (only the Run() inbound loop does that). ExecuteJob
was discarding the response with '_ = response', causing deliver=false
cron task results to never reach the target channel.

Now publish the response explicitly, matching the deliver=true and
command execution paths.
This commit is contained in:
王路路 2026-03-04 12:18:23 +08:00
parent df1b53fdf9
commit 4307c3a28a

View file

@ -337,7 +337,16 @@ func (t *CronTool) ExecuteJob(ctx context.Context, job *cron.CronJob) string {
return fmt.Sprintf("Error: %v", err) return fmt.Sprintf("Error: %v", err)
} }
// Response is automatically sent via MessageBus by AgentLoop // Send agent response to channel (ProcessDirectWithChannel does not
_ = response // Will be sent by AgentLoop // publish on its own — only the Run() inbound loop does that).
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" return "ok"
} }