Merge pull request #965 from Molecule-AI/fix/crlf-cron-prompts

fix(scheduler): strip CRLF from cron prompts (closes #958)
This commit is contained in:
Hongming Wang 2026-04-19 00:25:14 -07:00 committed by GitHub
commit 0111a882ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"log"
"net/http"
"strings"
"time"
"github.com/gin-gonic/gin"
@ -96,6 +97,10 @@ func (h *ScheduleHandler) Create(c *gin.Context) {
return
}
// Strip CRLF from prompts — org-template files committed on Windows
// inject \r\n, causing empty agent responses (issue #958).
body.Prompt = strings.ReplaceAll(body.Prompt, "\r", "")
if body.Timezone == "" {
body.Timezone = "UTC"
}
@ -161,6 +166,12 @@ func (h *ScheduleHandler) Update(c *gin.Context) {
return
}
// Strip CRLF from prompt if provided (issue #958).
if body.Prompt != nil {
clean := strings.ReplaceAll(*body.Prompt, "\r", "")
body.Prompt = &clean
}
// If cron_expr or timezone changed, revalidate and recompute next_run
var nextRunAt *time.Time
if body.CronExpr != nil || body.Timezone != nil {

View File

@ -0,0 +1,3 @@
-- Issue #958: Strip CRLF from cron prompts inserted from Windows org-template files.
-- Carriage returns cause empty agent responses and phantom-producing detection.
UPDATE workspace_schedules SET prompt = REPLACE(prompt, E'\r', '') WHERE prompt LIKE E'%\r%';