-
Notifications
You must be signed in to change notification settings - Fork 926
feat(agent-core): default print mode to steer with unbounded limits #1722
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
Merged
sailist
merged 1 commit into
MoonshotAI:main
from
sailist:feat/print-mode-steer-defaults
Jul 15, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@moonshot-ai/kimi-code": minor | ||
| --- | ||
|
|
||
| In print mode (`kimi -p`), keep the run alive by default while background tasks are pending and feed each completion back to the main agent as a new turn, with an effectively unbounded wait ceiling and turn cap and a 72-hour subagent timeout. Set `print_background_mode = "exit"` (or `"drain"`) to restore the previous exit-after-one-turn behavior. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import type { KimiConfig } from './schema'; | ||
|
|
||
| /** | ||
| * Print-mode (`kimi -p`) defaults for the v1 engine. A headless run should not | ||
| * be cut short by limits meant for interactive use, so every value here is | ||
| * "effectively unbounded". Explicit user config always wins over these. | ||
| */ | ||
|
|
||
| /** | ||
| * Wall-clock ceiling (seconds) for the drain/steer wait once the main turn | ||
| * ends: 10 years ≈ unbounded. | ||
| */ | ||
| export const PRINT_WAIT_CEILING_S_DEFAULT = 315_360_000; | ||
|
|
||
| /** Cap on extra turns steered by background-task completions: ≈ unbounded. */ | ||
| export const PRINT_MAX_TURNS_DEFAULT = 100_000; | ||
|
|
||
| /** | ||
| * Per-subagent (`Agent` / `AgentSwarm`, foreground and background) timeout: | ||
| * 72 hours ≈ none (the interactive default is 2 hours). | ||
| */ | ||
| export const PRINT_SUBAGENT_TIMEOUT_MS_DEFAULT = 259_200_000; | ||
|
|
||
| /** | ||
| * Merge print-mode defaults into the config bound to a new session. Only | ||
| * values the user left unset are filled (per-key spread order). | ||
| * | ||
| * `background` is deliberately untouched: its print defaults live next to the | ||
| * consuming code in `Session` (`resolvePrintBackgroundMode`, | ||
| * `waitForBackgroundTasksOnPrint`, `handlePrintMainTurnCompleted`), because | ||
| * `printBackgroundMode`'s fallback must keep honoring the legacy | ||
| * `keep_alive_on_exit` → `'drain'` mapping. | ||
| */ | ||
| export function applyPrintModeConfigDefaults(config: KimiConfig): KimiConfig { | ||
| return { | ||
| ...config, | ||
| // `0` is already what an unset maxStepsPerTurn means (unlimited); the | ||
| // explicit value just pins the print-mode contract. | ||
| loopControl: { maxStepsPerTurn: 0, ...config.loopControl }, | ||
| subagent: { timeoutMs: PRINT_SUBAGENT_TIMEOUT_MS_DEFAULT, ...config.subagent }, | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 an existing print-mode config explicitly sets
[background] keep_alive_on_exit = false(or the env override tofalse), this now resolves tosteerbecause thefalseresult 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 explicitfalseexit immediately; those users will unexpectedly keepkimi -palive for background completions unless they add a newprint_background_mode = "exit". Check whether the legacy option/env was present before falling through to the new default.Useful? React with 👍 / 👎.