kimi-code icon indicating copy to clipboard operation
kimi-code copied to clipboard

[Bug] kimi -p /goal exits 0 while the goal is still active

Open vastStage opened this issue 2 weeks ago • 0 comments

What version of Kimi Code is running?

2.6.3 (source main snapshot, 2026-11-18). Confirmed with a unit test.

Which open platform/subscription were you using?

None involved.

Which model were you using?

None involved.

What platform is your computer?

Windows 11 x64.

What issue are you seeing?

kimi -p "/goal ..." can exit with status 0 while the goal is still active.

When the goal does not reach a terminal state before print_wait_ceiling_s, applyPrintBackgroundPolicy warns print goal wait ceiling reached and returns. runNativeGoalTurn then calls goalExitCode('active'), which falls through to the default and returns 0. CI therefore sees success for an incomplete goal.

What steps can reproduce the bug?

  1. Run a goal that will not finish quickly:

    kimi -p "/goal <long-running objective>"
    
  2. Set a small print_wait_ceiling_s, or let the default ceiling expire.

  3. Observe the print goal wait ceiling reached warning.

  4. The process exits 0, and the goal summary still has status: active.

A unit-level reproduction is:

expect(goalExitCode('active')).toBe(GOAL_EXIT_CODES.complete); // currently passes, but is wrong

Running:

pnpm -C apps/kimi-code exec vitest run test/cli/goal-prompt.test.ts

with:

it('does not report success for an active goal', () => {
  expect(goalExitCode('active')).not.toBe(GOAL_EXIT_CODES.complete);
});

fails with expected +0 not to be +0.

What is the expected behavior?

A non-terminal goal should not exit with the success code. The docs currently define 0 for complete, 3 for blocked, and 6 for paused. active should either map to a non-zero code (for example paused, or a new incomplete code) or the process should keep waiting until the goal reaches a terminal state.

Additional information

Relevant code:

  • apps/kimi-code/src/cli/goal-prompt.ts — GOAL_EXIT_CODES / goalExitCode
  • apps/kimi-code/src/cli/v2/run-v2-print.ts — goal wait ceiling and exit-code assignment
  • packages/agent-core-v2/src/features/goal/goalOps.ts — active is a valid non-terminal status

The documented exit-code contract is in docs/en/guides/interaction.md (0 complete, 3 blocked, 6 paused), and the changelog for #1704 says kimi -p "/goal ..." stays alive until the goal reaches a terminal state.

Contribution

  • [x] I am willing to submit a PR for this bug fix myself. I will wait for a maintainer's /approve in this issue before opening the PR.

vastStage avatar Nov 18 '26 18:11 vastStage