mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
Merge pull request #2474 from srcrs/fix-cron-independent-sessions
fix(cron): make each job execution use an independent session
This commit is contained in:
+3
-1
@@ -6,6 +6,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/sipeed/picoclaw/pkg/bus"
|
||||
"github.com/sipeed/picoclaw/pkg/config"
|
||||
"github.com/sipeed/picoclaw/pkg/constants"
|
||||
@@ -340,7 +342,7 @@ func (t *CronTool) ExecuteJob(ctx context.Context, job *cron.CronJob) string {
|
||||
return "ok"
|
||||
}
|
||||
|
||||
sessionKey := fmt.Sprintf("cron-%s", job.ID)
|
||||
sessionKey := fmt.Sprintf("agent:cron-%s-%s", job.ID, uuid.New().String())
|
||||
|
||||
// Call agent with the job message
|
||||
response, err := t.executor.ProcessDirectWithChannel(
|
||||
|
||||
@@ -271,8 +271,8 @@ func TestCronTool_ExecuteJobPublishesAgentResponse(t *testing.T) {
|
||||
t.Fatalf("ExecuteJob() = %q, want ok", got)
|
||||
}
|
||||
|
||||
if executor.lastKey != "cron-job-1" {
|
||||
t.Fatalf("sessionKey = %q, want cron-job-1", executor.lastKey)
|
||||
if !strings.HasPrefix(executor.lastKey, "agent:cron-job-1-") {
|
||||
t.Fatalf("sessionKey = %q, want agent:cron-job-1-{uuid}", executor.lastKey)
|
||||
}
|
||||
if executor.lastChan != "telegram" || executor.lastChatID != "chat-1" {
|
||||
t.Fatalf("executor target = %s/%s, want telegram/chat-1", executor.lastChan, executor.lastChatID)
|
||||
|
||||
Reference in New Issue
Block a user