From 577eaaf642c77aa986a89b8dfec4cd9f038a6a13 Mon Sep 17 00:00:00 2001 From: Edwin Lim Date: Thu, 12 Feb 2026 11:41:22 -0500 Subject: [PATCH] don't show the entire conversation in error message --- src/lib/agent-interface.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/agent-interface.ts b/src/lib/agent-interface.ts index 8c36715..3b81bdd 100644 --- a/src/lib/agent-interface.ts +++ b/src/lib/agent-interface.ts @@ -626,16 +626,22 @@ export async function runAgent( } // Check for API errors (rate limits, etc.) + // Extract just the API error line(s), not the entire output + const apiErrorMatch = outputText.match(/API Error: [^\n]+/g); + const apiErrorMessage = apiErrorMatch + ? apiErrorMatch.join('\n') + : 'Unknown API error'; + if (outputText.includes('API Error: 429')) { logToFile('Agent error: RATE_LIMIT'); spinner.stop('Rate limit exceeded'); - return { error: AgentErrorType.RATE_LIMIT, message: outputText }; + return { error: AgentErrorType.RATE_LIMIT, message: apiErrorMessage }; } if (outputText.includes('API Error:')) { logToFile('Agent error: API_ERROR'); spinner.stop('API error occurred'); - return { error: AgentErrorType.API_ERROR, message: outputText }; + return { error: AgentErrorType.API_ERROR, message: apiErrorMessage }; } return completeWithSuccess();