Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Problem

Two related UI issues with tool display:

  1. Tool errors not displayed clearly: When an agent calls a tool that doesn't exist or is disabled by policy, the UI shows "Waiting for result..." indefinitely with no error indication.

  2. WRITE DENIED collapse not working: PR 🤖 Collapse WRITE DENIED errors by default #403 added logic to collapse WRITE DENIED errors by default, but it doesn't work because the component renders before the result is available.

Solution

Tool Error Display

Updated GenericToolCall and StreamingMessageAggregator to handle both error formats:

  • AI SDK tool-error events: { error: "..." }
  • Tool implementation errors: { success: false, error: "..." }

Changes:

  • Detect errors in both formats
  • Display errors in styled error box (consistent with BashToolCall, FileEditToolCall)
  • Mark status as "failed" instead of "completed" for errors

WRITE DENIED Collapse

Fixed FileEditToolCall to collapse when WRITE DENIED result arrives:

  • Added useEffect to watch for result changes
  • Collapses tool call when WRITE DENIED error is detected
  • Preserves initial expanded state calculation for other cases

Testing

  • All 740 unit tests pass
  • Type checking passes
  • Logic handles all tool types (specialized and generic)

Generated with cmux

Two fixes:

1. Tool error display: GenericToolCall now properly detects and displays
   tool errors in both formats ({ error: '...' } from AI SDK and
   { success: false, error: '...' } from tool implementations). Status
   is correctly shown as 'failed' instead of 'completed' for errors.

2. WRITE DENIED collapse: FileEditToolCall now uses useEffect to collapse
   when WRITE DENIED result arrives, fixing issue where initial render
   (before result available) would expand the tool call.

Both formats are now consistently handled across all tool types.
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