Skip to content

fix: report task stop reasons to the model - #1781

Merged
RealKai42 merged 2 commits into
mainfrom
xtr/report-task-stop-reasons
Jul 16, 2026
Merged

fix: report task stop reasons to the model#1781
RealKai42 merged 2 commits into
mainfrom
xtr/report-task-stop-reasons

Conversation

@kermanx

@kermanx kermanx commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

None; the problem is described below.

Problem

When a subagent or another managed task stopped before completion, the model-facing result did not consistently explain who stopped it or preserve a non-user stop reason. In particular, a task cancelled manually through the task API could reach the model as a generic killed task, making user intent indistinguishable from system failure.

What changed

  • Added an explicit stopByUser task operation that keeps user cancellation represented by the existing typed cancellation reason inside agent-core-v2.
  • Propagated manual cancellation from RPC and the REST task-cancel route through that operation.
  • Updated foreground subagent failures and background task notifications to say when the user stopped the work and to include other recorded stop reasons.
  • Added regression coverage for foreground subagents, background process notifications, Bash interruption, task tools, and the REST cancellation route.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset. Added a patch changeset for @moonshot-ai/kimi-code.
  • Ran gen-docs skill, or this PR needs no doc update. No docs update is needed because commands, configuration, and user workflows are unchanged; only model-facing task termination context changes.

Validation

  • pnpm --filter @moonshot-ai/agent-core-v2 typecheck
  • pnpm --filter @moonshot-ai/kap-server typecheck
  • pnpm --filter @moonshot-ai/agent-core-v2 lint:domain
  • pnpm --filter @moonshot-ai/agent-core-v2 exec vitest run test/tool/tool.test.ts test/agent/task/rpc-events.test.ts test/agent/task/taskManager.test.ts test/agent/task/tools/task-tools.test.ts test/os/backends/node-local/tools/bash.test.ts
  • pnpm --filter @moonshot-ai/kap-server exec vitest run test/tasks.test.ts

@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e25405b

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 16, 2026

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

commit: e25405b

@RealKai42
RealKai42 merged commit 09e8554 into main Jul 16, 2026
18 checks passed
@RealKai42
RealKai42 deleted the xtr/report-task-stop-reasons branch July 16, 2026 10:32
This was referenced Jul 16, 2026
ywh114 pushed a commit to ywh114/kimi-code that referenced this pull request Jul 19, 2026
* fix: report task stop reasons to the model

* chore: add task stop reason 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.

2 participants