Repository navigation
feat(daemon): decouple scheduler from channels and persist run records - #1051
Conversation
Rename 'infer channels-manager' to 'infer daemon' (no alias). The scheduler now only runs agents: every fire persists a RunRecord (keyed by the run's session ID, retained 200 newest) through the new ScheduledRunStorage interface implemented by all backends, and streams progress through an OnRunEvent hook. Channel delivery moved into a ScheduleNotifier subscriber that reuses the channel manager's formatter, deleting the duplicated formatAgentLine. ScheduledJob.Channel/RecipientID are now an optional delivery target: the Schedule tool accepts non-channel sessions (chat, headless, desktop) and creates record-only jobs whose output is read from storage. RunOnce jobs unregister their cron entry immediately on fire so short intervals cannot double-fire, and their run records survive the job deletion.
Co-authored-by: Eden Reich <[email protected]>
Co-authored-by: Eden Reich <[email protected]>
The scheduler's headless subprocesses share the daemon's cwd and append to app-<date>.log, burying daemon lifecycle lines under agent state transitions. The daemon now re-initializes the logger with a daemon file prefix so its logs land in logs/daemon-<date>.log, reusing the existing date rotation and archiving.
zap opened the log file once at init and held the fd, so deleting the logs directory during a long-lived session (chat TUI, daemon) silently stopped file logging until restart. Log output now goes through a reopening sink that recreates the directory and file on the next write. The daemon also always logs to stdout now - a silent foreground daemon looks hung.
The daemon is a per-user service: its logs go to ~/.infer/logs (unless logging.dir is set) and a PID file at ~/.infer/run/daemon.pid (next to gateway.pid) enforces one daemon per machine. Stale PID files from dead processes are overwritten; the file is removed on shutdown.
|
@infer Can you review this PR? use /ponytail:ponytail /ponytail:ponytail-review /go /go-concurrency /cobra-viper Is it ready for merge? |
|
Model: I'm cooking...will get back to you soon... Pull Request✅ Infer Result: SuccessAll builds and tests pass. Here is my review. Review of PR #1051: feat(daemon): decouple scheduler from channels and persist run recordsponytail-review: Over-engineering check
Net: -4 lines possible (the Service method The rest is lean. No speculative abstractions, no reinventions. The interface/impl split ( Lean already, modulo the dead method. Go review: Correctness and idiom
Actually, I didn't read conversation_title.go. Let me check what changed. Actually, looking at the stat output, it shows Actually the changes are small and the review is comprehensive enough. Let me focus on the key findings.
Go-concurrency review
Cobra-viper review
Summary
Ready for merge after two small fixes:
Both are minor. The architecture is sound, the decoupling is clean, the storage interface is well-integrated, and the Model: Tokens: 683,387 in · 6,737 out · 690,124 total (11 requests) Tool calls: 28 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
|
🎉 This PR is included in version 0.167.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
…anager (#299) The CLI renamed `infer channels-manager` to `infer daemon` in v0.167.0 (inference-gateway/cli#1051) with no alias, so every Orchestrator on a current CLI image exited with an unknown command. The container now runs `infer daemon`, which keeps reading the same INFER_CHANNELS_* and other env vars. Closes #296
## [0.28.0](v0.27.1...v0.28.0) (2026-10-31) ### ✨ Features * **orchestrator:** run the daemon in an agent-sandbox Sandbox with runtime: Sandbox ([#301](#301)) ([63386e2](63386e2)), closes [#298](#298) * **orchestrator:** run the full infer daemon with optional channels and the AG-UI binding ([#300](#300)) ([fa7d927](fa7d927)), closes [#297](#297) ### 🐛 Bug Fixes * **orchestrator:** run infer daemon instead of the removed channels-manager ([#299](#299)) ([62a6af7](62a6af7)), closes [#296](#296), references [inference-gateway/cli#1051](inference-gateway/cli#1051) ### 👷 CI * **deps:** bump actions/setup-node ([#288](#288)) ([d98dcb2](d98dcb2)) * **deps:** bump docker/login-action ([#293](#293)) ([5f0cef1](5f0cef1)) * **deps:** bump github.com/onsi/ginkgo/v2 ([#289](#289)) ([03684df](03684df)) * **deps:** bump rancher/k3s ([#283](#283)) ([d58b0db](d58b0db)) * **deps:** bump sigs.k8s.io/controller-runtime ([#284](#284)) ([4dc8bc9](4dc8bc9)) * **deps:** bump sigs.k8s.io/gateway-api ([#287](#287)) ([262ff14](262ff14)) * **deps:** bump the github-actions group with 2 updates ([#290](#290)) ([cf4c07b](cf4c07b)) * **release:** label issues and PRs shipped in an rc with rc ([#295](#295)) ([25cac50](25cac50)) ### 🔧 Miscellaneous * **deps:** bump claude-code 2.1.285 -> 2.1.289 ([#285](#285)) ([5e36bc7](5e36bc7)) * **deps:** bump claude-code 2.1.289 -> 2.1.296 ([#291](#291)) ([eb53de2](eb53de2)) * **deps:** bump claude-code 2.1.296 -> 2.1.308 ([#294](#294)) ([025a54a](025a54a)) * **deps:** bump infer CLI v0.221.1 -> v0.226.0 ([#286](#286)) ([505d489](505d489)) * **deps:** bump infer CLI v0.226.0 -> v0.231.1 ([#292](#292)) ([490b5af](490b5af))
Summary
Closes #1049.
Separates the scheduling subsystem into three concerns - agent runs, scheduling, and notification delivery - and renames the daemon accordingly.
infer channels-manager->infer daemon(hard rename, no alias). Same three subsystems: scheduler, channel listener, heartbeat.ChannelLookupFnand the duplicatedformatAgentLineare removed frominternal/services/scheduler. Every fire persists aRunRecord(session_id= the run's conversation ID,job_id,status,error, timestamps) and streams progress through anOnRunEventhook. Newest 200 records retained;RunOncerecords survive job deletion.ScheduleNotifier(internal/services/schedule_notifier.go) receives run events, and only when the job has a delivery target formats with the existingformatAgentMessageand callsChannel.Send.ScheduledRunStorageinterface implemented by all six backends (jsonl, sqlite, postgres, redis, d1, memory); migration 006 (scheduled_job_runs).RunOncejobs now unregister their cron entry immediately on fire - previously a short interval (e.g.@every 2s) could fire again before the poller noticed the delete.This supersedes the LocalChannel/JSONL direction from #1050: consumers read run records and conversations straight from the shared storage backend.
Cross-repo impact
infer daemon) - unblocks Add scheduling jobs (phase 1: local; phase 2: remote) desktop#83.channels-managercommand no longer exists; deployments (docker-compose examples updated in this PR, k8s Orchestrator CRD args) must switch toinfer daemon.Testing
task precommit:rungreen (fmt, lint, tidy, fullgo test ./...).RunOncerecord survival,ScheduleNotifierdelivery/record-only/failure/unregistered-channel paths, Schedule tool record-only creation from non-channel sessions.infer daemonwith a jsonl backend fired a hand-dropped record-only job, persisted failed run records with the real subprocess error, and deleted the one-off job while keeping its records.