feat(agent-core): default print mode to steer with unbounded limits - #1722
Conversation
- change the default print background mode from 'exit' to 'steer' so `kimi -p` stays alive while background tasks are pending and each completion steers a new main turn - add print-mode config defaults (applyPrintModeConfigDefaults): effectively unbounded wait ceiling and turn cap, 72h subagent timeout; explicit user config always wins - thread the new `uiMode` option from SDKRpcClient through KimiCore into session create/resume - clamp setTimeout delays to 0x7fffffff so huge timeouts are not clamped to 1ms by Node
🦋 Changeset detectedLatest commit: da21e40 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: da21e40899
ℹ️ 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".
| parseEnv: parseBooleanEnv, | ||
| }); | ||
| return keepAliveOnExit ? 'drain' : 'exit'; | ||
| return keepAliveOnExit ? 'drain' : 'steer'; |
There was a problem hiding this comment.
Preserve explicit keep-alive false as exit
When an existing print-mode config explicitly sets [background] keep_alive_on_exit = false (or the env override to false), this now resolves to steer because the false result is treated the same as the unset default. The new behavior is documented here as defaulting to steer only “when neither is set,” while the legacy mapping made explicit false exit immediately; those users will unexpectedly keep kimi -p alive for background completions unless they add a new print_background_mode = "exit". Check whether the legacy option/env was present before falling through to the new default.
Useful? React with 👍 / 👎.
Related Issue
None — see Problem below.
Problem
In print mode (
kimi -p), a headless run exited as soon as the main turn finished (defaultprint_background_mode = "exit"). Background tasks the agent had launched were abandoned, and their completions never fed back into the run — even though a headless invocation has no user around to continue the work. The limits that did exist (1h wait ceiling, 50 steered turns, 2h subagent timeout) were also tuned for interactive use and could cut a long headless run short.What changed
1. Default print background mode:
exit→steerProblem: a
kimi -prun finished after one turn even with background tasks still pending.What was done:
Session.resolvePrintBackgroundModenow falls back to'steer'when neitherprint_background_modenor the legacykeep_alive_on_exitis set, so the run stays alive while background tasks are pending and each completion steers a new main turn.print_background_mode = "exit"(or"drain") restores the previous behavior; the legacykeep_alive_on_exit = true→'drain'mapping is unchanged.2. Print-mode config defaults
Problem: interactive-tuned limits (1h wait ceiling, 50 steered turns, 2h subagent timeout) could cut a headless run short.
What was done:
applyPrintModeConfigDefaults(config/print-defaults.ts) fills only values the user left unset: an effectively unboundedprint_wait_ceiling_s(~10 years) andprint_max_turns(100k), a 72h subagent timeout, andmax_steps_per_turn = 0.uiModeoption is threaded fromSDKRpcClientthroughKimiCoreinto session create/resume (withPrintModeDefaults); the raw user config is left untouched so config reads/writes still round-trip the file values.3. Timer clamp for huge timeouts
Problem: Node clamps
setTimeoutdelays above0x7fffffffto 1ms, so an "effectively unbounded" timeout would fire immediately.What was done:
timeoutOutcome/resettableTimeoutOutcomenow clamp delays toMAX_TIMER_DELAY_MS(~24.8 days).Tests: new
KimiCore print-mode defaultssuite intest/harness/runtime.test.ts(defaults applied, explicit user config wins, defaults off outside print mode, defaults applied on session reload) and updatedhandlePrintMainTurnCompletedcases intest/session/lifecycle-hooks.test.ts.Checklist
gen-changesetsskill, or this PR needs no changeset. (.changeset/print-mode-steer-defaults.mdincluded)gen-docsskill, or this PR needs no doc update.