Skip to content

fix(todo-list): accept 'completed' status and normalize to 'done'#1229

Open
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:main
Open

fix(todo-list): accept 'completed' status and normalize to 'done'#1229
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:main

Conversation

@bj456736

Copy link
Copy Markdown
Contributor

Closes #1016

Problem
The LLM sometimes passes completed as the status for TodoList items, but the schema only accepted pending | in_progress | done. This produced two problems:

  1. Validation failed when the model used completed.
  2. Even if validation passed, statusMarker() had no case for completed and fell through to the unreachable default branch.

Changes

  • Extend TodoStatus union to include completed so it is accepted at the type level.
  • Map completeddone in setTodos() so persisted state stays clean.
  • Handle completed in statusMarker() so it renders as [done].
  • Update the markdown description to explicitly warn against using completed.
  • Add a test confirming completed is accepted and mapped to done.

Testing

  • pnpm -C packages/agent-core test tools/todo-list.test.ts
  • Full agent-core suite: 3254 tests passed ✅

Closes MoonshotAI#1016

The LLM sometimes passes 'completed' as the status for TodoList items,
but the schema only accepted 'pending' | 'in_progress' | 'done'. This
produced two problems:

1. Validation failed when the model used 'completed'.
2. Even if validation passed, statusMarker() had no case for 'completed'
   and fell through to the unreachable default branch.

Changes:
- Extend TodoStatus union to include 'completed' so it is accepted at
  the type level.
- Map 'completed' -> 'done' in setTodos() so persisted state stays
  clean.
- Handle 'completed' in statusMarker() so it renders as '[done]'.
- Update the markdown description to explicitly warn against using
  'completed'.
- Add a test confirming 'completed' is accepted and mapped to 'done'.
@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8d4dd8b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 30, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@8d4dd8b
npx https://pkg.pr.new/@moonshot-ai/kimi-code@8d4dd8b

commit: 8d4dd8b

@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: 8d4dd8bed3

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

title: z.string().min(1).describe('Short, actionable title for the todo.'),
status: z.enum(['pending', 'in_progress', 'done']).describe('Current status of the todo.'),
status: z
.preprocess((val) => (val === 'completed' ? 'done' : val), z.enum(['pending', 'in_progress', 'done']))

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 Keep invalid todo statuses rejected

In the live tool-call path, tool-call.ts only compiles tool.parameters with AJV and passes the original parsedArgs.data into resolveExecution, so this zod preprocess is not run during execution. Because toInputJsonSchema renders the input side of a preprocess as an unconstrained transform input, the generated JSON Schema drops the pending | in_progress | done enum for status; calls such as { todos: [{ title: 'x', status: 'wip' }] } can now validate and be persisted/rendered instead of being rejected. The new test calls executeTool directly, so it misses this validator path.

Useful? React with 👍 / 👎.

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的时候,出现了参数错误,没法完整展示todolist

1 participant