Skip to content

Conversation

@ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Dec 9, 2025

Problem

When in Plan Mode, file edit tools (file_edit_*) are disabled via tool policy. However, the model doesn't know about this policy and may still attempt to call these tools*.

When this happens:

  1. The AI SDK emits a tool-error event with the error message
  2. The error output was { error: "Model tried to call unavailable tool..." }
  3. The frontend's hasFailureResult() only checked for success === false
  4. Since there was no success field, the tool call showed "completed" status instead of "failed"

This made it appear the edit succeeded when it actually failed, and the error wasn't visible in the dropdown.

Solution

Update hasFailureResult() to infer failure from the presence of an error field, not just explicit success: false:

function hasFailureResult(result: unknown): boolean {
  if (typeof result !== "object" || result === null) return false;
  // Explicit failure
  if ("success" in result && result.success === false) return true;
  // Implicit failure - error field present
  if ("error" in result && result.error) return true;
  return false;
}

This is more defensive and handles any tool error that includes an error field, regardless of whether success is explicitly set.

*This only appears to happen when the context includes usage of those tools. I assume this isn't an easily solvable problem as an agent author, the model sees the tool is disabled, but it also sees it being used dozens of times in the context. How does it know it's really disabled?


Generated with mux

@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

When determining tool call status, check for both explicit failure
(success: false) and implicit failure (error field present). This
ensures failed tool calls show 'failed' status even when the backend
doesn't explicitly set success: false.
@ethanndickson ethanndickson force-pushed the pencil-emoji-edit-failure branch from 5c7ee66 to 972311d Compare December 9, 2025 01:55
@ethanndickson ethanndickson added this pull request to the merge queue Dec 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 9, 2025
@ethanndickson ethanndickson added this pull request to the merge queue Dec 9, 2025
Merged via the queue into main with commit dd1d753 Dec 9, 2025
19 checks passed
@ethanndickson ethanndickson deleted the pencil-emoji-edit-failure branch December 9, 2025 03:16
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.

1 participant