fix(agent-core): classify user-cancelled tool telemetry correctly#630
fix(agent-core): classify user-cancelled tool telemetry correctly#630Cyning12 wants to merge 1 commit into
Conversation
Use cancelledByUser on tool results instead of guessing outcome from output text, fixing Bash user interrupts misreported as errors. Fixes MoonshotAI#583 Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: 679db40 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 679db4069d
ℹ️ 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".
| if (result.cancelledByUser === true) return 'cancelled'; | ||
| return 'error'; |
There was a problem hiding this comment.
Preserve cancelled telemetry for Agent tool cancels
When a user stops a foreground Agent tool call, the tool handles isUserCancellation(signal.reason) itself and returns { output: ..., isError: true } with the “manually interrupted this subagent” message (checked packages/agent-core/src/tools/builtin/collaboration/agent.ts lines 283-303 and 309-318), but it does not set cancelledByUser. Because this new classifier now treats every unflagged error as error, those user-cancelled Agent calls regress from the old string heuristic’s cancelled outcome to error; either propagate the new flag from that tool path or keep a safe fallback for known internal cancellation outputs.
Useful? React with 👍 / 👎.
…onshotAI#630 Mark C2关账、勾选验收项,invoke README 链 PR;PROMPT 路径改 done/。 Co-authored-by: Cursor <cursoragent@cursor.com>
Related Issue
Fixes #583
Problem
tool_calltelemetry inferredoutcomefrom tool output text. Bash user interrupts (Interrupted by user) were recorded aserrorinstead ofcancelled, while some real errors containing words likeabortedorcancelledcould be misclassified ascancelled.What changed
cancelledByUser?: trueonExecutableToolErrorResult, set on user abort paths intool-call.tsandbash.tsviaisUserCancellation.telemetryToolOutcome/telemetryToolErrorTypetotool-telemetry.ts; classify cancelled outcomes from the structured flag instead of string heuristics.@moonshot-ai/agent-coreand@moonshot-ai/kimi-code.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.Test plan
pnpm exec tsc -p tsconfig.json --noEmit(packages/agent-core)pnpm exec vitest run test/agent/turn.test.ts test/loop/tool-call.e2e.test.ts test/tools/bash.test.ts test/tools/shell-cancel.test.ts(119 passed)pnpm lint(0 errors)sleep 30+ Stop → telemetryoutcome: cancelledMade with Cursor