Skip to content

fix(learn): drop parallel-tool-call cancellations from corrections#1662

Open
season179 wants to merge 1 commit intortk-ai:developfrom
season179:fix/learn-cancellation-misclass-1659
Open

fix(learn): drop parallel-tool-call cancellations from corrections#1662
season179 wants to merge 1 commit intortk-ai:developfrom
season179:fix/learn-cancellation-misclass-1659

Conversation

@season179
Copy link
Copy Markdown

Closes #1659.

rtk learn treated Claude Code's parallel-tool-call cancellations as CLI errors, so the next adjacent command got emitted as the "fix" — dominating the output (reporter: 5060 lines / 251 KB on a 30-day window).

Filter the cancellation marker at both sides of the correction-pair search: is_command_error rejects it as wrong-side; the inner-loop iterator filters before take(WINDOW) so cancellations don't consume lookahead slots and hide a real fix after them. Gated on is_error=true so a successful command whose stdout merely mentions the phrase stays eligible.

5 new unit tests cover the issue's repro plus edge cases (window-consumption, success-with-phrase, all-caps, mid-stream mention, leading whitespace).

`rtk learn` was treating Claude Code's parallel-tool-call cancellations
(`<tool_use_error>Cancelled: parallel tool call ...`) as CLI errors, so
when a user Ctrl-C'd one branch of a fan-out the next adjacent command
got emitted as the "fix". On a 30-day window this dominates the output
(reporter saw 5060 lines / 251 KB of mostly bogus rules).

Filter cancellations at both sides of the correction-pair search:
- `is_command_error` rejects them as the wrong-side
- the inner-loop iterator filters them before `take(WINDOW)` so they
  don't consume lookahead slots and hide a valid fix after them

Filter is gated on `is_error=true` so a successful command whose stdout
merely echoes the phrase (build logs, etc.) stays eligible.

Closes rtk-ai#1659.
@pszymkowiak pszymkowiak added bug Something isn't working effort-small Quelques heures, 1 fichier filter-quality Filter produces incorrect/truncated signal labels May 1, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Filters out Claude Code's parallel-tool-call cancellation markers from the correction-pair detection in rtk learn. The cancellation events were being misclassified as CLI errors, causing the next adjacent command to be emitted as a bogus "fix" and dominating output. The fix adds a regex-based filter at both the error-detection and lookahead-window stages of correction finding.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #1659


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working effort-small Quelques heures, 1 fichier filter-quality Filter produces incorrect/truncated signal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants