feat(kimi-code): keep print-mode goal runs alive until the goal settles - #1712
Conversation
- applyPrintBackgroundPolicy waits for goal continuation turns via a goalActive hook before applying the exit/drain/steer mode, bounded by the wait ceiling - createPrintTurnEndings skips the timeout when the remaining budget is not finite - update the changeset to cover the goal-run lifecycle
|
| Name | Type |
|---|---|
| @moonshot-ai/kimi-code | Patch |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a 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: 4240e4ec90
ℹ️ 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".
| const ended = await input.turnEndings.next( | ||
| goalDeadline - input.now(), | ||
| input.skipTurnId, | ||
| ); |
There was a problem hiding this comment.
Wake the goal wait on terminal goal updates
When a goal stops without producing another turn.ended after this wait starts (for example, a continuation launch fails and the goal service pauses the goal via goal.updated after handling the same turn end), this loop waits only on turnEndings.next. If the current turn end was already consumed before goalActive() observes the pause, no further turn ending arrives, so kimi -p "/goal ..." remains alive until print_wait_ceiling_s (default 3600s) instead of immediately printing the paused/blocked summary; the wait should also be woken by terminal goal updates or otherwise re-check after the goal service settles.
Useful? React with 👍 / 👎.
Related Issue
No linked issue — the problem is explained below. (This is the one remaining piece of #1710, which duplicated the already-merged #1704 and was closed.)
Problem
On the experimental engine (agent-core-v2),
kimi -p "/goal ..."exited right after the first turn even when the goal was stillactive. v2 drives goal continuation by launching new turns (v1 keeps a single turn alive across the whole goal), and the print runner only awaited the first turn's result, so the cleanup path cancelled the continuation turn milliseconds after it started — multi-turn goals could never complete in print mode. This contradicts the documented headless-goal contract ("the goal driver keeps the prompt's turn-run alive across continuation turns until the goal reaches a terminal state").What changed
applyPrintBackgroundPolicy) gains agoalActiveprobe: while a goal isactive, the run keeps waiting for continuation turns regardless of theprint_background_mode, bounded byprint_wait_ceiling_sas a safety net (with a warning if hit). Once the goal reaches a terminal state, the normal exit / drain / steer policy applies, and the goal summary still drives the exit code.turn.endedcollector accepts a non-finite wait budget (no timer) used by the goal wait.Goal [complete] (turns: 3), exit 0), a 1-turn budget blocks the goal (Goal [blocked], exit 3).Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.