diff --git a/pkg/tools/cron.go b/pkg/tools/cron.go index f2e6561df..a9547eba9 100644 --- a/pkg/tools/cron.go +++ b/pkg/tools/cron.go @@ -357,7 +357,7 @@ func (t *CronTool) ExecuteJob(ctx context.Context, job *cron.CronJob) string { } if response != "" { - t.executor.PublishResponseIfNeeded(ctx, channel, chatID, "", response) + t.executor.PublishResponseIfNeeded(ctx, channel, chatID, sessionKey, response) } return "ok" } diff --git a/pkg/tools/cron_test.go b/pkg/tools/cron_test.go index d46d365a0..0e527c98a 100644 --- a/pkg/tools/cron_test.go +++ b/pkg/tools/cron_test.go @@ -24,6 +24,7 @@ type stubJobExecutor struct { publishedResp string publishedChan string publishedChatID string + publishedKey string } func (s *stubJobExecutor) ProcessDirectWithChannel( @@ -47,6 +48,7 @@ func (s *stubJobExecutor) PublishResponseIfNeeded( s.publishedResp = response s.publishedChan = channel s.publishedChatID = chatID + s.publishedKey = sessionKey } func newTestCronToolWithExecutorAndConfig(t *testing.T, executor JobExecutor, cfg *config.Config) *CronTool { @@ -283,6 +285,9 @@ func TestCronTool_ExecuteJobPublishesAgentResponse(t *testing.T) { if executor.publishedResp != "generated reply" { t.Fatalf("published response = %q, want generated reply", executor.publishedResp) } + if executor.publishedKey != executor.lastKey { + t.Fatalf("published sessionKey = %q, want %q", executor.publishedKey, executor.lastKey) + } if executor.publishedChan != "telegram" || executor.publishedChatID != "chat-1" { t.Fatalf("published target = %s/%s, want telegram/chat-1", executor.publishedChan, executor.publishedChatID) }