From 02d9ff8db27ec4a52faa283fbcad00c10ba742c3 Mon Sep 17 00:00:00 2001 From: Abhimanyu Yadav <122007096+Abhi1992002@users.noreply.github.com> Date: Wed, 3 Dec 2025 14:49:29 +0530 Subject: [PATCH] fix(frontend): improve error message extraction in agent execution error handler (#11527) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When agent execution fails, the error toast was only showing `error.message`, which often lacks detail. The API returns more specific error messages in `error.response.detail.message`, but these weren't being displayed to users, making debugging harder. Screenshot 2025-12-03 at 2 14 17 PM ### Changes 🏗️ - Updated error message extraction in `useAgentRunModal` to check `error.response.detail.message` first, then fall back to `error.message`, then to the default message - This ensures users see the most specific error message available from the API response ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Triggered an agent execution error (e.g., invalid inputs) and verified the toast shows the detailed error message from `error.response.detail.message` - [x] Verified fallback to `error.message` when `error.response.detail.message` is not available - [x] Verified fallback to default message when neither is available --- .../components/modals/RunAgentModal/useAgentRunModal.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentModal/useAgentRunModal.ts b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentModal/useAgentRunModal.ts index 2e8fc02d97..92f9c2703c 100644 --- a/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentModal/useAgentRunModal.ts +++ b/autogpt_platform/frontend/src/app/(platform)/library/agents/[id]/components/NewAgentLibraryView/components/modals/RunAgentModal/useAgentRunModal.ts @@ -87,9 +87,13 @@ export function useAgentRunModal( } }, onError: (error: any) => { + const errorMessage = error.isGraphValidationError() + ? error.response.detail.message + : error.message; + toast({ title: "❌ Failed to execute agent", - description: error.message || "An unexpected error occurred.", + description: errorMessage || "An unexpected error occurred.", variant: "destructive", }); },