Skip to content

fix(cli): keep a session goal running when a message arrives - #14101

Merged
marius-kilocode merged 2 commits into
mainfrom
prevent-goal-interruption-on-active-prompt
Sep 14, 2026
Merged

marius-kilocode merged 2 commits into
mainfrom
prevent-goal-interruption-on-active-prompt

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Sending a message while a session goal was active paused the goal. The user had to resume it manually. This contradicts how other agent products treat a mid-run message, where the message steers or queues and the loop keeps running, and it makes it hard to add context during a long goal.

Why This Change Was Made

The goal loop paused the goal for any real user message. A user message should preempt the current goal continuation for its turn but leave the goal active. The prompt queue already hands off to a newer prompt and marks the interrupted turn as superseded; the goal runner now detects that handoff and loops again after the user's turn instead of settling the goal to paused.

The goal still stops on goal_report, Stop, /goal pause, /goal clear, or a real failure/no-progress turn. Shell commands and slash commands still pause it.

User Impact

  • A message sent during a goal is answered, then the goal continues automatically.
  • The goal stops only when the model reports completion or a blocker, the user presses Stop, or the user runs /goal pause or /goal clear.
  • Goal help text and the goals documentation describe the new behavior.

Evidence

  • bun test ./test/kilocode/session/goal.test.ts: 76 pass.
  • bun test ./test/kilocode/session-prompt-queue.test.ts ./test/kilocode/session-prompt-steering.test.ts: 26 pass.
  • bun test ./test/session/prompt.test.ts: 75 pass, 1 skip.
  • bun run typecheck in packages/opencode: clean.
  • bun run script/check-opencode-annotations.ts --worktree: all shared changes annotated.

A real user message now takes priority for its turn but no longer pauses an active goal. The goal loop resumes after the user's turn and only stops on goal_report, Stop, or an explicit /goal pause or clear.
@kilo-code-bot

kilo-code-bot Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The three prior suggestions are all addressed in 60bb54b0fc: markSuperseded is now gated on an active goal and consumeSuperseded clears the session's whole marker set, the preemption return now runs after the blocked()/failed() checks, and the test polls the queue before releasing the gate.

Files Reviewed (4 files)
  • packages/opencode/src/kilocode/session/goal/runner.ts
  • packages/opencode/src/kilocode/session/prompt-queue.ts
  • packages/opencode/src/session/prompt.ts
  • packages/opencode/test/kilocode/session/goal.test.ts
Previous Review Summary (commit 5665631)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 5665631)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 3
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/opencode/src/kilocode/session/prompt-queue.ts 128 Non-goal superseded markers are only reclaimed when the queue fully drains; they can accumulate in a continuously non-empty queue.
packages/opencode/src/kilocode/session/goal/runner.ts 425 Preemption short-circuits before the blocked()/failed() checks, so a failed/blocked turn plus a user message continues the goal, conflicting with documented failure-pauses behavior.
packages/opencode/test/kilocode/session/goal.test.ts 777 gate.resolve() can race the forked human prompt; if the prompt is not yet enqueued, hasFollowup is false and the test flakes.
Files Reviewed (7 files)
  • .changeset/goal-continues-after-message.md
  • packages/kilo-docs/pages/code-with-ai/agents/goals.md
  • packages/opencode/src/kilocode/session/goal/instructions.ts
  • packages/opencode/src/kilocode/session/goal/runner.ts - 1 issue
  • packages/opencode/src/kilocode/session/prompt-queue.ts - 1 issue
  • packages/opencode/src/session/prompt.ts
  • packages/opencode/test/kilocode/session/goal.test.ts - 1 issue

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0

Review guidance: REVIEW.md from base branch main

Record superseded markers only while a goal is active, and clear the whole session marker set on consume. Let a blocked or failed goal turn take precedence over a user-message handoff. Wait for the human prompt to queue before releasing the test gate.
@marius-kilocode
marius-kilocode merged commit 8530bd5 into main Sep 14, 2026
34 checks passed
@marius-kilocode
marius-kilocode deleted the prevent-goal-interruption-on-active-prompt branch September 14, 2026 08:09
lambertjosh added a commit that referenced this pull request Sep 14, 2026
Account for #14101 and #13951 after the original sync. Verify notification channels against #13771 and widget layouts against Kilo-Org/cloud#5620. Clarify partial change summaries from cloud#5810 and remove implementation-heavy prose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants