← Starchild Wiki

Automation自动化

Scheduled tasks, background processes, and the promise rule定时任务、后台进程,与“承诺规则”

scheduled_task · sessions_spawn · bash_process

01Two execution modes两种执行模式

Scheduled work runs in one of two modes, and the choice between them is a cost decision.定时工作以两种模式之一运行,二者之间的选择是一个成本决策。

A task is a full agent run every tick: it can reason, use tools, and respond to what it finds — capable, but each tick costs an LLM call. A command is a direct script invocation: near-free, and exactly right for deterministic work like fetching and pushing a file.task 是每个 tick 一次完整的 Agent 运行:能推理、能用工具、能应对所见——能力强,但每个 tick 都要花一次 LLM 调用。command 是直接调用脚本:几乎免费,正适合取文件、推文件这类确定性工作。

The scheduler runs on UTC, and the script is the source of truth — the schedule only points at it. Data is always fetched inside the script, never read from memory or pasted in, because LLMs hallucinate numbers and a stale number is worse than no number.调度器按 UTC 运行,脚本是真相源——调度只指向它。数据始终在脚本内部抓取,绝不从记忆里读或粘贴进来,因为 LLM 会幻觉出数字,而过期数字比没有数字更糟。

02Cost transparency before activation激活前的成本透明

No recurring job activates without the user seeing what it will cost.任何周期性任务在激活之前,用户都必须先看到它的成本。

The estimate is concrete: runs per day times cost per run, shown both as a daily and a monthly figure. High-frequency polling is not refused — it is priced. If a job polls every minute, it gets a cost line like anything else, and a cheaper variant is offered: a coarser interval, or a command mode, or fewer steps per run.预估是具体的:每天运行次数乘以每次运行成本,分别给出每日与每月的数字。高频轮询不会被拒绝——只会被定价。若某任务每分钟轮询一次,它和其他任务一样会得到一行成本,并会被提供一个更便宜的方案:更粗的间隔、改用 command 模式,或每次运行更少的步骤。

Pricing first, then permission. The user decides; the system's job is to make the decision honest. A job is created in a "dry-run" state if that is what the user asked for, and it stays there until the estimate has been seen.先定价,再授权。决定权在用户;系统的职责是让这个决定诚实。若用户要求,任务会以「试运行」状态创建,在预估被看到之前一直停留于此。

03Background work and the promise rule后台工作与承诺规则

Long work runs in a background session or a detached process — and a hard rule governs how a turn may end.长任务在后台会话或分离进程中运行——而一条硬性规则约束着一轮对话如何收尾。

The rule: never end a turn on a bare promise. A time-bound promise must register a scheduled task in the same turn. A completion-bound promise must spawn a watcher that notices when the job finishes. Nothing wakes the agent otherwise — so an unregistered promise is a lie.规则是:绝不在空头承诺上结束一轮。带时间约束的承诺必须在同一轮注册一个定时任务;带完成约束的承诺必须派生一个能察觉任务结束的 watcher。除此之外没有任何东西会唤醒 Agent——所以未注册的承诺就是谎言。

04The delivery chain交付链

A background job that produces artifacts is not done when the files exist.产出文件的后台任务,在文件存在的那一刻并没有完成。

It is done when the artifacts reach the user — pushed to a channel, added to the site, written into a report. Integration is scripted into the job itself, so delivery cannot be forgotten; the last step of the job is the delivery. If that final step fails, the job fails — a produced-but-undelivered artifact is still an unfinished job.当产物真正送达用户才算完成——推到频道、加入站点、写进报告。集成被写进任务脚本本身,因此交付不可能被遗忘;任务的最后一步就是交付。若最后一步失败,任务就是失败——产出了却未交付,仍然算未完成。

05Observability可观测性

“What's running?” aggregates three surfaces, so the answer is always one screen away.「现在在跑什么?」汇总三个层面,答案始终就在一个界面之外。

The three surfaces are registered scheduled jobs, live background processes, and auto-started preview services. Cost is attributed per caller — job:, chat:, preview: — which makes credit drain diagnosable instead of mysterious, including the resident services that never appear in any task list.三个层面是:已注册的定时任务、存活的后台进程、自动启动的预览服务。成本按调用方归属——job:chat:preview:——这让额度流失可诊断而非神秘,包括那些从不出现在任何任务清单里的常驻服务。