feat(v2-print): align kimi -p run lifecycle with the default engine#2017
feat(v2-print): align kimi -p run lifecycle with the default engine#2017sailist wants to merge 1 commit into
Conversation
…13 files) - add applyPrintModeConfigDefaults in agent-core-v2: fill print-mode config defaults (bash task timeout / max steps per turn / subagent timeout all unbounded) into the memory layer, respecting user-set keys - applyPrintBackgroundPolicy: keep the run alive while cron tasks have future fires so their steered turns can run, with an anti-spin guard for wedged ticks; goal/cron waiting shares the steer ceiling budget - default print background mode changed from exit to steer - add task.bashTaskTimeoutS config key and wire it into BashTool's detachTimeoutMs - v2 print runner now forwards turn.step.retrying events to writeRetrying - allow subagent timeoutMs = 0 (no timeout)
🦋 Changeset detectedLatest commit: 20fc0ce The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 20fc0ce128
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| * never have a subagent killed by a wall-clock cap; only the model itself may | ||
| * stop one. | ||
| */ | ||
| export const PRINT_SUBAGENT_TIMEOUT_MS_DEFAULT = 0; |
There was a problem hiding this comment.
Treat zero swarm timeout as unbounded
In print mode this default is written to [subagent], and AgentSwarmTool passes resolveSubagentTimeoutMs() through as task.timeout to AgentRunBatch; that scheduler arms setTimeout whenever the timeout is defined, so 0 aborts immediately rather than disabling the cap. Any AgentSwarm call under kimi -p without an explicit subagent timeout will fail right away, so either map 0 to undefined at the swarm boundary or make the batch scheduler treat 0 as no timeout.
Useful? React with 👍 / 👎.
| detached: startsInBackground, | ||
| timeoutMs, | ||
| detachTimeoutMs: DEFAULT_BACKGROUND_TIMEOUT_S * MS_PER_SECOND, | ||
| detachTimeoutMs: this.detachTimeoutMs(), |
There was a problem hiding this comment.
Apply bashTaskTimeoutS to initially backgrounded commands
When run_in_background=true and the tool call omits timeout, timeoutMs is still computed from the built-in background default (normalizeTimeoutMs(args.timeout, true), 600s); this new config value is only supplied as detachTimeoutMs, which is applied when a foreground task is later detached. In kimi -p, applyPrintModeConfigDefaults sets bashTaskTimeoutS=0, but commands that start directly in the background will still be killed after 10 minutes unless the model also sends disable_timeout=true.
Useful? React with 👍 / 👎.
| const ended = await input.turnEndings.next( | ||
| Math.max(fireAt - input.now(), 0) + CRON_FIRE_GRACE_MS, | ||
| input.skipTurnId, |
There was a problem hiding this comment.
Cap cron waits at the print ceiling
When the next cron fire is beyond printWaitCeilingS, this waits until fireAt + grace instead of the remaining ceiling budget. Because createPrintTurnEndings.next() uses a ref'd timer, a run configured with a small ceiling (for example 60s) and a cron scheduled hours later will stay alive until that cron fire rather than honoring the ceiling; clamp this wait to deadline - now and finish/warn when the ceiling is reached.
Useful? React with 👍 / 👎.
Related Issue
No linked issue — the problem is explained below.
Problem
In the v2 engine, the
kimi -p(print mode) run lifecycle diverged from the default engine in several ways:exit, so a run could terminate even while cron tasks still had future fires waiting to be steered.BashToolhad no configurable background task timeout, and subagents could not opt out of the timeout entirely.turn.step.retrying) were not surfaced in print output.What changed
1. Print-mode config defaults
applyPrintModeConfigDefaultsinagent-core-v2: fills print-mode config defaults (bash task timeout / max steps per turn / subagent timeout, all unbounded) into the memory layer while respecting user-set keys.task.bashTaskTimeoutSconfig key and wired it intoBashTool'sdetachTimeoutMs.timeoutMs = 0to mean no timeout.2. Print background lifecycle
exittosteer.applyPrintBackgroundPolicy: keeps the run alive while cron tasks have future fires so their steered turns can run, with an anti-spin guard for wedged ticks; goal/cron waiting shares the steer ceiling budget.3. Print output
turn.step.retryingevents towriteRetrying.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.