fix: fix agents limit exceeded error + allow deletions in /agents (#678)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -91,6 +91,23 @@ function getResourceLimitMessage(e: APIError): string | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the error is an agent limit error (429 with agents-limit-exceeded)
|
||||
*/
|
||||
function isAgentLimitError(e: APIError): boolean {
|
||||
if (e.status !== 429) return false;
|
||||
|
||||
const errorBody = e.error;
|
||||
if (errorBody && typeof errorBody === "object") {
|
||||
if ("reasons" in errorBody && Array.isArray(errorBody.reasons)) {
|
||||
if (errorBody.reasons.includes("agents-limit-exceeded")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the error is a credit exhaustion error (402 with not-enough-credits)
|
||||
*/
|
||||
@@ -152,6 +169,18 @@ export function formatErrorDetails(
|
||||
return `You've hit your usage limit. ${resetInfo}. View usage: ${LETTA_USAGE_URL}`;
|
||||
}
|
||||
|
||||
// Check for agent limit error (free tier agent count limit)
|
||||
if (isAgentLimitError(e)) {
|
||||
const { billingTier } = getErrorContext();
|
||||
|
||||
if (billingTier?.toLowerCase() === "free") {
|
||||
return `You've reached the agent limit (3) for the Free Plan. Delete agents at: ${LETTA_AGENTS_URL}\nOr upgrade to Pro for unlimited agents at: ${LETTA_USAGE_URL}`;
|
||||
}
|
||||
|
||||
// Fallback for paid tiers (shouldn't normally hit this, but just in case)
|
||||
return `You've reached your agent limit. Delete agents at: ${LETTA_AGENTS_URL}\nOr check your plan at: ${LETTA_USAGE_URL}`;
|
||||
}
|
||||
|
||||
// Check for resource limit error (e.g., "You have reached your limit for agents")
|
||||
const resourceLimitMsg = getResourceLimitMessage(e);
|
||||
if (resourceLimitMsg) {
|
||||
|
||||
Reference in New Issue
Block a user