Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/drop-kimi-resume-refs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

Remove references to the non-existent `kimi resume` command from the scheduled-task tool descriptions.
2 changes: 1 addition & 1 deletion docs/en/configuration/data-locations.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Inside each session directory:
- **`agents/agent-0/` etc.**: sub-Agent instance directories, each containing their own `wire.jsonl`.
- **`logs/kimi-code.log`**: diagnostic log for this session; only present when a diagnostic event occurs.
- **`tasks/`**: background task persistence — `tasks/<task_id>.json` stores status/pid/exit code; `tasks/<task_id>/output.log` stores output.
- **`cron/`**: scheduled task persistence; reloaded into the scheduler when `kimi resume` runs. See [Scheduled tasks](../reference/tools.md#scheduled-tasks).
- **`cron/`**: scheduled task persistence; reloaded into the scheduler when the session is resumed with `kimi --session`. See [Scheduled tasks](../reference/tools.md#scheduled-tasks).

## Built-in tool cache

Expand Down
2 changes: 1 addition & 1 deletion docs/en/guides/use-cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Check the production health endpoint every hour and let me know if anything look
Come back in about 10 minutes and check whether the build has finished.
```

Scheduled tasks are bound to their session — closing the terminal is fine, and they are reloaded and continue firing when you run `kimi resume` on the same session. They are not carried into brand-new sessions. Recurring tasks expire after 7 days — the agent receives a `stale` signal on the final trigger and decides whether to stop or renew based on your original instructions.
Scheduled tasks are bound to their session — closing the terminal is fine, and they are reloaded and continue firing when you resume the same session with `kimi --session`. They are not carried into brand-new sessions. Recurring tasks expire after 7 days — the agent receives a `stale` signal on the final trigger and decides whether to stop or renew based on your original instructions.

To see what tasks are currently pending, just ask the agent (it calls the read-only `CronList` tool). To cancel a task, tell the agent to remove it or reference its 8-character ID. For the full tool reference, see [Scheduled tasks](../reference/tools.md#scheduled-tasks). The global kill switch is `KIMI_DISABLE_CRON=1`.

Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Background task tools manage tasks started via `Bash`, `Agent`, or `AskUserQuest

## Scheduled Tasks

Scheduled task tools allow the Agent to re-inject a prompt into the current session at a future time — either as a one-time reminder or as a recurring cron-triggered task (periodic checks, daily reports, deployment monitoring, etc.). Schedules are bound to the session and remain active after `kimi resume`, but are not carried into a brand-new session. A single session can hold at most 50 active scheduled tasks. Set `KIMI_DISABLE_CRON=1` to disable them entirely; see [Environment Variables](../configuration/env-vars.md#运行时开关).
Scheduled task tools allow the Agent to re-inject a prompt into the current session at a future time — either as a one-time reminder or as a recurring cron-triggered task (periodic checks, daily reports, deployment monitoring, etc.). Schedules are bound to the session and remain active when you resume it with `kimi --session`, but are not carried into a brand-new session. A single session can hold at most 50 active scheduled tasks. Set `KIMI_DISABLE_CRON=1` to disable them entirely; see [Environment Variables](../configuration/env-vars.md#运行时开关).

| Tool | Default Approval | Description |
| --- | --- | --- |
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/configuration/data-locations.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ $KIMI_CODE_HOME (默认 ~/.kimi-code)
- **`agents/agent-0/` 等**:子 Agent 实例目录,各自含 `wire.jsonl`。
- **`logs/kimi-code.log`**:该会话的诊断日志,只有发生诊断事件时才存在。
- **`tasks/`**:后台任务持久化——`tasks/<task_id>.json` 保存状态/pid/退出码,`tasks/<task_id>/output.log` 保存输出。
- **`cron/`**:定时任务持久化,`kimi resume` 时重新加载到调度器。详见[定时任务](../reference/tools.md#定时任务)。
- **`cron/`**:定时任务持久化,`kimi --session` 恢复会话时重新加载到调度器。详见[定时任务](../reference/tools.md#定时任务)。

## 内置工具缓存

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/guides/use-cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ src/parser/markdown.ts 目前几乎没有测试。请补一组单元测试,覆
大约 10 分钟之后再回来,确认一下构建是否结束。
```

定时计划绑定在会话内:关掉终端没关系,对同一个会话执行 `kimi resume` 时会重新加载并继续触发;但它们不会带入全新的会话。周期任务在 7 天后会自动过期——Agent 会在最后一次触发时收到 `stale` 提示,可根据你之前的指示决定结束还是续期。
定时计划绑定在会话内:关掉终端没关系, `kimi --session` 恢复同一个会话时会重新加载并继续触发;但它们不会带入全新的会话。周期任务在 7 天后会自动过期——Agent 会在最后一次触发时收到 `stale` 提示,可根据你之前的指示决定结束还是续期。

想查看当前有哪些挂起的任务,直接问 Agent 即可(它会调用只读的 `CronList` 工具);要取消某个任务,让 Agent 删除它或引用对应的 8 位 id。完整工具说明见[定时任务](../reference/tools.md#定时任务);整体关停开关是 `KIMI_DISABLE_CRON=1`。

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/reference/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Plan 模式是一种受约束的工作状态:进入后 `Write` 与 `Edit` 只

## 定时任务

定时任务工具允许 Agent 把一段 prompt 在未来某个时间重新注入到当前会话——既可以是一次性提醒,也可以是按 cron 周期触发的任务(定期巡检、每日报表、部署监控等)。计划绑定到会话,执行 `kimi resume` 后仍然有效,但不会带入全新的会话。单个会话最多保留 50 个生效中的定时任务。设置 `KIMI_DISABLE_CRON=1` 可整体禁用,详见[环境变量](../configuration/env-vars.md#运行时开关)。
定时任务工具允许 Agent 把一段 prompt 在未来某个时间重新注入到当前会话——既可以是一次性提醒,也可以是按 cron 周期触发的任务(定期巡检、每日报表、部署监控等)。计划绑定到会话, `kimi --session` 恢复会话后仍然有效,但不会带入全新的会话。单个会话最多保留 50 个生效中的定时任务。设置 `KIMI_DISABLE_CRON=1` 可整体禁用,详见[环境变量](../configuration/env-vars.md#运行时开关)。

| 工具 | 默认审批 | 说明 |
| --- | --- | --- |
Expand Down
5 changes: 2 additions & 3 deletions packages/agent-core-v2/src/session/cron/tools/cron-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ Use `recurring: false` for "remind me at X" style requests, single deadlines, "i
## Session lifetime

Cron tasks live in the current kimi CLI session. When you exit, they
are persisted under the session homedir; the next `kimi resume` of the
same session reloads them and the scheduler resumes from each task's
`createdAt`. Fire times that fell during the offline window are
are persisted under the session homedir; resuming the same session
reloads them and the scheduler resumes from each task's `createdAt`. Fire times that fell during the offline window are
collapsed into a single delivery via `coalescedCount` (and recurring
tasks past their 7-day window arrive with `stale: true` as their final
delivery).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Tasks live in `ISessionCronService` (Session scope) and are persisted
* through the App-scoped `ICronTaskPersistence` under the project's cron
* scope, so a `kimi resume` of the same session reloads them and the
* scope, so resuming the same session reloads them and the
* scheduler picks up where it left off (fires that fell during downtime
* are collapsed into a single delivery with `coalescedCount`). Tasks do
* NOT carry over into a brand-new session.
Expand Down
4 changes: 2 additions & 2 deletions packages/agent-core-v2/src/session/cron/tools/cron-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Guidelines:
cancel or modify a schedule, route the request through the model
(i.e. call `CronDelete` or `CronCreate` on their behalf).
- The empty case returns `cron_jobs: 0\nNo cron jobs scheduled.`. Cron
tasks survive a `kimi resume` of the same session but do not bleed
into new sessions.
tasks survive a resume of the same session but do not bleed into new
sessions.
- After a context compaction, or whenever you are unsure which cron
jobs are live, call this tool to re-enumerate them rather than
guessing ids from earlier in the conversation.
Expand Down
24 changes: 13 additions & 11 deletions packages/agent-core/src/agent/cron/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
* - translate a fired `CronTask` into a `steer(...)` call carrying a
* `CronJobOrigin`, plus the `cron_fired` telemetry event;
* - mirror every store mutation to `<sessionDir>/cron/<id>.json`
* (via {@link addTask} / {@link removeTasks}) so that `kimi resume`
* can call {@link loadFromDisk} to rehydrate previously-scheduled
* tasks. When no `sessionDir` is supplied (subagents, tests,
* ephemeral sessions) the manager stays purely in-memory.
* (via {@link addTask} / {@link removeTasks}) so that a resumed
* session can call {@link loadFromDisk} to rehydrate
* previously-scheduled tasks. When no `sessionDir` is supplied
* (subagents, tests, ephemeral sessions) the manager stays purely
* in-memory.
* - provide a `handleMissed(...)` entry point that future boot-time
* missed-task notification will call. Today the scheduler's
* `coalescedCount` semantics handle missed fires inline, so this
Expand Down Expand Up @@ -143,7 +144,7 @@ export class CronManager {
* `sessionDir` was supplied — the manager then behaves as pure
* in-memory, matching pre-persistence semantics. When defined,
* `addTask` / `removeTasks` schedule fire-and-forget writes so a
* later `kimi resume` can reload via {@link loadFromDisk}.
* later session resume can reload via {@link loadFromDisk}.
*/
private readonly persistStore: PerIdJsonStore<CronTask> | undefined;

Expand Down Expand Up @@ -241,9 +242,9 @@ export class CronManager {

/**
* Persist the scheduler's `lastFiredAt` cursor for a recurring task
* so a `kimi resume` does not coalesce-replay an already-delivered
* fire. Called by the scheduler's `onAdvanceCursor` callback after a
* successful recurring fire.
* so resuming the session does not coalesce-replay an
* already-delivered fire. Called by the scheduler's `onAdvanceCursor`
* callback after a successful recurring fire.
*
* No-op when the task has already been removed between fire and
* callback (concurrent CronDelete is the canonical case). When
Expand All @@ -261,9 +262,10 @@ export class CronManager {
}

/**
* Rehydrate the in-memory store from `<sessionDir>/cron/` after
* `kimi resume`. No-op when persistence is not attached. Idempotent:
* clears the in-memory map and re-inserts every record on disk.
* Rehydrate the in-memory store from `<sessionDir>/cron/` after the
* session is resumed. No-op when persistence is not attached.
* Idempotent: clears the in-memory map and re-inserts every record on
* disk.
*
* Tasks are inserted via {@link SessionCronStore.adopt} so the
* original `id` and `createdAt` survive — `createdAt` is the
Expand Down
5 changes: 2 additions & 3 deletions packages/agent-core/src/tools/cron/cron-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ Use `recurring: false` for "remind me at X" style requests, single deadlines, "i
## Session lifetime

Cron tasks live in the current kimi CLI session. When you exit, they
are persisted under the session homedir; the next `kimi resume` of the
same session reloads them and the scheduler resumes from each task's
`createdAt`. Fire times that fell during the offline window are
are persisted under the session homedir; resuming the same session
reloads them and the scheduler resumes from each task's `createdAt`. Fire times that fell during the offline window are
collapsed into a single delivery via `coalescedCount` (and recurring
tasks past their 7-day window arrive with `stale: true` as their final
delivery).
Expand Down
4 changes: 2 additions & 2 deletions packages/agent-core/src/tools/cron/cron-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* cron cadence (`recurring: true`, the default).
*
* Tasks live in `SessionCronStore` and are mirrored to
* `<sessionDir>/cron/<id>.json` via `CronManager.addTask`, so a
* `kimi resume` of the same session reloads them and the scheduler
* `<sessionDir>/cron/<id>.json` via `CronManager.addTask`, so resuming
* the same session reloads them and the scheduler
* picks up where it left off (fires that fell during downtime are
* collapsed into a single delivery with `coalescedCount`). Tasks do
* NOT carry over into a brand-new session.
Expand Down
4 changes: 2 additions & 2 deletions packages/agent-core/src/tools/cron/cron-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Guidelines:
cancel or modify a schedule, route the request through the model
(i.e. call `CronDelete` or `CronCreate` on their behalf).
- The empty case returns `cron_jobs: 0\nNo cron jobs scheduled.`. Cron
tasks survive a `kimi resume` of the same session but do not bleed
into new sessions.
tasks survive a resume of the same session but do not bleed into new
sessions.
- After a context compaction, or whenever you are unsure which cron
jobs are live, call this tool to re-enumerate them rather than
guessing ids from earlier in the conversation.
Expand Down
6 changes: 3 additions & 3 deletions packages/agent-core/src/tools/cron/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export interface CronSchedulerOptions {
* Optional. Called after a recurring task fires successfully, with
* the wall-clock timestamp of the last ideal occurrence whose
* jittered delivery has just been delivered. The manager wires this
* to `store.markFired(id, ts)` + a per-id JSON write so a
* `kimi resume` does not replay the fire.
* to `store.markFired(id, ts)` + a per-id JSON write so resuming the
* session does not replay the fire.
*
* Fire-and-forget: the scheduler does not wait for persistence to
* settle. One-shot tasks do not invoke this callback (the
Expand Down Expand Up @@ -172,7 +172,7 @@ export function createCronScheduler(opts: CronSchedulerOptions): CronScheduler {
const parsedCache = new Map<string, ParsedCronExpression>();

// Per-task wall-clock baseline for "where did we last look from".
// Now persisted across `kimi resume` via `task.lastFiredAt`: when
// Now persisted across session resumes via `task.lastFiredAt`: when
// the scheduler first sees a task whose `lastFiredAt` is set and
// not in the future, that timestamp seeds this map so resume does
// not coalesce-replay already-delivered recurring fires. A bogus
Expand Down
7 changes: 4 additions & 3 deletions packages/agent-core/src/tools/cron/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
* - `recurring` — undefined / true means "fire repeatedly until deleted
* or auto-expired"; false means "fire once then auto-delete".
* - `lastFiredAt` — wall-clock epoch ms of the last ideal occurrence
* whose jittered delivery has actually completed. Persisted so a
* `kimi resume` does not replay already-delivered recurring fires:
* without it, the scheduler would fall back to `createdAt` and
* whose jittered delivery has actually completed. Persisted so
* resuming the session does not replay already-delivered recurring
* fires: without it, the scheduler would fall back to `createdAt`
* and
* coalesce yesterday's already-fired 09:00 into today's tick. A
* value greater than the current wall clock is treated as corrupt
* and the scheduler falls back to `createdAt` for that task.
Expand Down
2 changes: 1 addition & 1 deletion packages/agent-core/test/agent/cron/resume.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* The manager's `addTask` / `removeTasks` wrappers mirror every mutation
* to `<sessionDir>/cron/<id>.json`, and `loadFromDisk()` re-populates
* the in-memory store on `kimi resume`. The scheduler's
* the in-memory store when the session is resumed. The scheduler's
* `createdAt`-based baseline is what makes a reloaded task fire
* correctly even when ideal fire times landed during downtime — these
* tests pin down both sides of the contract.
Expand Down
Loading