Skip to content

fix(agent-core): nudge todo reconciliation when a turn ends with unfinished todos - #2373

Open
airudotsh wants to merge 2 commits into
MoonshotAI:mainfrom
airudotsh:fix/todo-turn-end-reminder
Open

fix(agent-core): nudge todo reconciliation when a turn ends with unfinished todos#2373
airudotsh wants to merge 2 commits into
MoonshotAI:mainfrom
airudotsh:fix/todo-turn-end-reminder

Conversation

@airudotsh

Copy link
Copy Markdown

Closes #2372

What

Adds a turn-end reconciliation rule to TodoListReminderInjector: when the previous turn ended (latest assistant step made no tool calls) with unfinished todos and no TodoList write on the way out, the next step gets a reminder immediately, instead of waiting out the 10-turn cadence.

Why

The existing reminder only fires after 10 assistant turns since the last TodoList write. The common failure — work finished, turn ended, bookkeeping forgotten — completes in far fewer turns, so the reminder never fires and the todo list stays silently stale.

How

  • Trigger: latest assistant message has no tool calls (turn complete) AND no TodoList write in that final step AND at least one unfinished todo.
  • Noise control: separate spacing (3 assistant turns since the last reminder), never fires when all todos are done or when the final step was itself a TodoList write. The 10-turn cadence rule is untouched.
  • The reminder text tells the agent to either mark items done / clear the stale list, or continue with the remaining items, and lists only the unfinished items.

Tests

  • 5 new injector tests: turn-end fires below the cadence threshold, skipped mid-turn, skipped when final step was a write, skipped when all done, reminder spacing.
  • Existing fixtures updated to distinguish mid-turn steps (tool call in flight) from turn-end steps; all 10 injector tests pass.
  • tsc --noEmit and oxlint clean on the touched files.

Copilot AI review requested due to automatic review settings July 29, 2026 14:27
@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 81f48ee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aae8d7f52f

ℹ️ 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".

Comment on lines +133 to +137
function turnEndedWithoutTodoWrite(history: readonly ContextMessage[]): boolean {
const lastAssistant = history.findLast((message) => message.role === 'assistant');
if (lastAssistant === undefined) return false;
if (lastAssistant.toolCalls.length > 0) return false;
return true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor same-turn TodoList writes before nudging

When a normal tool-use turn calls TodoList, receives its tool result, and then sends a final assistant response with no tool calls, this helper still returns true because it only inspects that final assistant message. If the list still has pending/in_progress items and the reminder spacing is met, the next user prompt gets a turn-end reminder immediately after a fresh TodoList update, which defeats the intended “no TodoList write on the way out” noise control. Please check for TodoList writes across the just-finished turn, not just on the terminal assistant step.

Useful? React with 👍 / 👎.

…nder

Addresses review feedback: the turn-end check now scans the whole
just-finished turn (back to the user prompt that started it) for a TodoList
write, so a mid-turn update followed by a closing text reply no longer
triggers a spurious reminder. Also adds the required changeset.
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.

TodoList reminder misses turn-end reconciliation (unfinished todos after turn end)

2 participants