Skip to content

fix(cron): invert stateless gate to match UI label#1139

Open
codebit0 wants to merge 1 commit into
nextlevelbuilder:mainfrom
codebit0:fix/cron-stateless-semantics
Open

fix(cron): invert stateless gate to match UI label#1139
codebit0 wants to merge 1 commit into
nextlevelbuilder:mainfrom
codebit0:fix/cron-stateless-semantics

Conversation

@codebit0
Copy link
Copy Markdown
Contributor

Summary

  • The cron handler reset the session when stateless=false and skipped reset when stateless=true — the opposite of every UI locale's label (en/ko/zh/vi all say "each run starts fresh without loading previous messages").
  • One-character logic fix in cmd/gateway_cron.go (if !job.Statelessif job.Stateless) so runtime matches the UI contract. Comment block reworded for clarity.
  • No DB migration: existing values were set by users based on the UI label, so they already encode the intended behavior.

Impact

A daily ETL cron with stateless=true was observed accumulating 38 messages over 18 days, causing the LLM to short-circuit tool calls and replay prior assistant turns (silent ETL failure — cron reported `status=ok` while DB rows were never written).

After the fix:

  • stateless=true → session reset every run (matches UI label, intended for ETL/one-shot jobs)
  • stateless=false → session preserved across runs (multi-run dialog crons)

Test plan

  • `go build ./...` (PG build)
  • `go build -tags sqliteonly ./...` (Desktop build)
  • `go vet ./cmd/...`
  • After deploy: confirm a `stateless=true` cron's session row has `messages = '[]'` after the first post-fix run
  • Confirm a `stateless=false` cron retains prior turns (regression check)

The cron job handler reset the session when stateless=false and skipped
reset when stateless=true — the opposite of what every UI locale labels
the field (en/ko/zh/vi all describe stateless as "each run starts fresh
without loading previous messages").

The buggy gate caused stateless=true crons to silently accumulate session
history across every execution, leading to context bloat and increasing
the chance of LLMs short-circuiting tool calls in favor of replaying
prior assistant turns. One affected daily ETL cron grew to 38 messages
over 18 days before the regression was noticed.

Fix: gate the Reset on `if job.Stateless` so the runtime matches the UI
contract. No DB migration is required — existing values were set by users
based on the UI label, so they already encode the intended behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant