Skip to content

Conversation

@uinstinct
Copy link
Contributor

@uinstinct uinstinct commented Oct 24, 2025

Description

Earlier, the cli used to match for tool errors and cancellations by searching those words in the tool call result. This approach produced errors when the tool call was successful but contained the "error" and "cancelled" words. This PR fixes it.

  • removes string matching for error and cancel
  • throws errors inside the tool call itself
  • update searchCode, writeFile, readFile, listFiles, fetch tools to throw errors instead of returning strings

resolves CON-3796

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screen recording or screenshot

before

image

after

image

Tests

[ What tests were added or updated to ensure the changes work as expected? ]


Summary by cubic

Refactored CLI tool error handling to throw structured errors and propagate execution status, replacing fragile string matching. This prevents false cancellations/errored states and ensures accurate tool result statuses in the UI.

  • Bug Fixes

    • Removed string matching for "error" and "cancelled"; use explicit ToolStatus from execution.
    • Permission denials produce canceled entries; execution failures produce errored entries; successful runs are done.
  • Refactors

    • Tools now throw ContinueError/Error instead of returning error strings (searchCode, readFile, listFiles, writeFile, fetch, status).
    • Added ToolResultWithStatus and updated executeStreamedToolCalls and handleToolCalls to pass status through chat history.

@uinstinct uinstinct requested a review from a team as a code owner October 24, 2025 10:27
@uinstinct uinstinct requested review from Patrick-Erichsen and removed request for a team October 24, 2025 10:27
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 24, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 9 files

Prompt for AI agents (all 3 issues)

Understand the root cause of the following 3 issues and fix them.


<file name="extensions/cli/src/tools/searchCode.ts">

<violation number="1" location="extensions/cli/src/tools/searchCode.ts:104">
Treating ripgrep exit code 1 as a thrown error regresses the tool: it now fails whenever a search has no matches, whereas ripgrep uses that code to signal an empty result set. Please continue returning the &quot;No matches found&quot; message so successful searches without hits don’t show up as tool errors.</violation>
</file>

<file name="extensions/cli/src/tools/writeFile.ts">

<violation number="1" location="extensions/cli/src/tools/writeFile.ts:165">
Wrapping the caught error in a new Error discards ContinueError reasons and errno metadata, so upstream tool handling always sees an unknown failure reason.</violation>
</file>

<file name="extensions/cli/src/tools/readFile.ts">

<violation number="1" location="extensions/cli/src/tools/readFile.ts:55">
Use ContinueErrorReason.FileNotFound when the target file is missing so downstream tooling can recognize the specific &quot;file not found&quot; condition instead of an unspecified error.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Oct 27, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 27, 2025
@sestinj sestinj merged commit ab214e3 into continuedev:main Oct 27, 2025
69 of 71 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Oct 27, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Oct 27, 2025
@uinstinct uinstinct deleted the cli-tool-error-throw branch October 28, 2025 03:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants