-
Notifications
You must be signed in to change notification settings - Fork 907
feat(agent-core): add session-scoped cron tools with persistence #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
58398b5
eb2329e
e3e1039
cb94ef8
98e50bb
7313c0c
4d16970
6a1dd7e
dffbaf6
8678167
b11eac4
2fa086d
a4b4b38
c1c9812
3f9eeae
59d64fa
d9ac5a7
6d09cfc
85885b8
79c0c2e
26414a6
ba655b2
84d1061
9944df3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@moonshot-ai/agent-core": minor | ||
| "@moonshot-ai/kimi-code": minor | ||
| --- | ||
|
|
||
| Add session-scoped scheduled prompts so the assistant can register, list, and cancel recurring or one-shot reminders that fire later in the same session. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,6 +97,12 @@ const INTERNAL_ORIGINS = new Set<PromptOrigin['kind']>([ | |
| 'system_trigger', | ||
| 'compaction_summary', | ||
| 'hook_result', | ||
| // Cron fires are stored as user-role records carrying a `<cron-fire ...>` | ||
| // XML envelope meant only for the model. Replay and the TUI projector | ||
| // already hide them; the markdown exporter must do the same or the raw | ||
| // protocol XML leaks into the user-facing export. | ||
| 'cron_job', | ||
| 'cron_missed', | ||
|
Comment on lines
+104
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a fired cron job has assistant/tool output in history, filtering only the cron-origin user message leaves the following assistant/tool records in the current export turn. For example, Useful? React with 👍 / 👎. |
||
| ]); | ||
|
|
||
| export function isInternalMessage(msg: ContextMessage): boolean { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,23 @@ export interface BackgroundTaskOrigin { | |
| readonly notificationId: string; | ||
| } | ||
|
|
||
| export interface CronJobOrigin { | ||
| readonly kind: 'cron_job'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Adding this internal origin means cron fire messages now enter Useful? React with 👍 / 👎. |
||
| readonly jobId: string; | ||
| readonly cron: string; | ||
| readonly recurring: boolean; | ||
| /** Number of theoretical fires that were collapsed into this single delivery (>= 1). */ | ||
| readonly coalescedCount: number; | ||
| /** True for recurring tasks past the 7-day age threshold. */ | ||
| readonly stale: boolean; | ||
| } | ||
|
|
||
| export interface CronMissedOrigin { | ||
| readonly kind: 'cron_missed'; | ||
| /** Number of one-shot tasks bundled into this missed-fire notification. */ | ||
| readonly count: number; | ||
| } | ||
|
|
||
| export interface HookResultOrigin { | ||
| readonly kind: 'hook_result'; | ||
| readonly event: string; | ||
|
|
@@ -55,6 +72,8 @@ export type PromptOrigin = | |
| | CompactionSummaryOrigin | ||
| | SystemTriggerOrigin | ||
| | BackgroundTaskOrigin | ||
| | CronJobOrigin | ||
| | CronMissedOrigin | ||
|
Comment on lines
+75
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Adding Useful? React with 👍 / 👎. |
||
| | HookResultOrigin; | ||
|
|
||
| export type ContextMessage = Message & { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { CronManager, type CronManagerOptions } from './manager'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a resumed transcript contains a cron fire that produced assistant/tool output, this branch skips the cron user message without advancing the replay turn or suppressing the rest of that turn. The following assistant/tool records are still rendered, but with the previous (or undefined)
currentTurnId, so scheduled-job output can be attached to the prior user prompt or replayed as an orphan. Either render a cron marker/advance the turn here, or skip the entire cron turn consistently.Useful? React with 👍 / 👎.