diff --git a/cmd/gateway_cron.go b/cmd/gateway_cron.go
index 8bb4d920..3e60482a 100644
--- a/cmd/gateway_cron.go
+++ b/cmd/gateway_cron.go
@@ -27,7 +27,15 @@ var cronHeartbeatWakeFn func(agentID string)
func makeCronJobHandler(sched *scheduler.Scheduler, msgBus *bus.MessageBus, cfg *config.Config, channelMgr *channels.Manager, sessionMgr store.SessionStore, agentStore store.AgentStore) func(job *store.CronJob) (*store.CronJobResult, error) {
return func(job *store.CronJob) (*store.CronJobResult, error) {
agentID := job.AgentID
- if agentID == "" {
+ if agentID == "" && agentStore != nil {
+ // Resolve real default agent from DB instead of using literal "default" string.
+ tenantCtx := store.WithTenantID(context.Background(), job.TenantID)
+ if defaultAgent, err := agentStore.GetDefault(tenantCtx); err == nil {
+ agentID = defaultAgent.AgentKey
+ } else {
+ agentID = cfg.ResolveDefaultAgentID()
+ }
+ } else if agentID == "" {
agentID = cfg.ResolveDefaultAgentID()
} else if id, err := uuid.Parse(agentID); err == nil && agentStore != nil {
// Resolve agentKey from UUID so session key uses agentKey
diff --git a/ui/web/src/pages/cron/cron-detail/cron-overview-tab.tsx b/ui/web/src/pages/cron/cron-detail/cron-overview-tab.tsx
index 7d8b214a..df461ddd 100644
--- a/ui/web/src/pages/cron/cron-detail/cron-overview-tab.tsx
+++ b/ui/web/src/pages/cron/cron-detail/cron-overview-tab.tsx
@@ -57,7 +57,7 @@ export function CronOverviewTab({ job, onUpdate }: CronOverviewTabProps) {
await onUpdate(job.id, {
schedule,
message: message.trim(),
- agentId: agentId.trim() || undefined,
+ agentId: agentId.trim() || "",
enabled,
});
setEditingMessage(false);
@@ -176,7 +176,7 @@ export function CronOverviewTab({ job, onUpdate }: CronOverviewTabProps) {
-