@@ -5,14 +5,17 @@ import type { AgentReplayRecord } from '../../rpc/resumed';
55 *
66 * A record starts a new user turn when it is a user-role message that came
77 * from an actual user action — a typed prompt, a user-invoked skill/plugin
8- * slash command, or a `!` shell command's input line. System-originated user
9- * messages (compaction summaries, cron fires, hook results, retries, goal
10- * reminders, background-task results, injections) continue the current turn
11- * instead — with one exception: `goal_continuation` prompts. The goal driver
12- * fires one synthetic continuation prompt per goal turn (see
13- * agent/turn/index.ts), and the goal system itself counts those as turns, so
14- * replay trimming treats them as turn boundaries; otherwise a 100-round goal
15- * would count as a single user turn and resume would replay the entire run.
8+ * slash command, a `!` shell command's input line, or a cron delivery
9+ * (`cron_job` / `cron_missed`). Scheduled fires are real rounds of work with
10+ * their own prompts and reports; counting them keeps resume replay bounded for
11+ * sessions dominated by many scheduled turns. Other system-originated user
12+ * messages (compaction summaries, hook results, retries, goal reminders,
13+ * background-task results, injections) continue the current turn instead —
14+ * with one exception: `goal_continuation` prompts. The goal driver fires one
15+ * synthetic continuation prompt per goal turn (see agent/turn/index.ts), and
16+ * the goal system itself counts those as turns, so replay trimming treats them
17+ * as turn boundaries; otherwise a 100-round goal would count as a single user
18+ * turn and resume would replay the entire run.
1619 *
1720 * Source of truth for turn-boundary detection; the TUI mirrors this through
1821 * the SDK re-export instead of keeping its own predicate.
@@ -32,10 +35,11 @@ export function isAgentReplayUserTurnRecord(record: AgentReplayRecord): boolean
3235 case 'shell_command' :
3336 // A `!` command's input is a user-turn anchor; its output is not.
3437 return message . origin . phase === 'input' ;
35- case 'background_task' :
36- case 'compaction_summary' :
3738 case 'cron_job' :
3839 case 'cron_missed' :
40+ return true ;
41+ case 'background_task' :
42+ case 'compaction_summary' :
3943 case 'hook_result' :
4044 case 'injection' :
4145 case 'retry' :
0 commit comments