Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Hotfix): Track reason for Error AgentState #7584

Merged
merged 12 commits into from
Mar 31, 2025
4 changes: 4 additions & 0 deletions frontend/src/components/agent-status-map.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ export const AGENT_STATUS_MAP: {
message: I18nKey.CHAT_INTERFACE$AGENT_RATE_LIMITED_MESSAGE,
indicator: IndicatorColor.YELLOW,
},
[AgentState.BUDGET_EXCEEDED]: {
message: I18nKey.CHAT_INTERFACE$AGENT_BUDGET_EXCEEDED_MESSAGE,
indicator: IndicatorColor.RED,
},
};
1 change: 1 addition & 0 deletions frontend/src/i18n/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export enum I18nKey {
CHAT_INTERFACE$AGENT_RUNNING_MESSAGE = "CHAT_INTERFACE$AGENT_RUNNING_MESSAGE",
CHAT_INTERFACE$AGENT_AWAITING_USER_INPUT_MESSAGE = "CHAT_INTERFACE$AGENT_AWAITING_USER_INPUT_MESSAGE",
CHAT_INTERFACE$AGENT_RATE_LIMITED_MESSAGE = "CHAT_INTERFACE$AGENT_RATE_LIMITED_MESSAGE",
CHAT_INTERFACE$AGENT_BUDGET_EXCEEDED_MESSAGE = "CHAT_INTERFACE$AGENT_BUDGET_EXCEEDED_MESSAGE",
CHAT_INTERFACE$AGENT_PAUSED_MESSAGE = "CHAT_INTERFACE$AGENT_PAUSED_MESSAGE",
LANDING$TITLE = "LANDING$TITLE",
LANDING$SUBTITLE = "LANDING$SUBTITLE",
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/i18n/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,21 @@
"tr": "Ajan hız sınırına ulaştı",
"ja": "エージェントがレート制限中"
},
"CHAT_INTERFACE$AGENT_BUDGET_EXCEEDED_MESSAGE": {
"en": "Budget Exceeded",
"zh-CN": "预算已超出",
"zh-TW": "預算已超出",
"de": "Budget überschritten",
"ko-KR": "예산 초과",
"no": "Budsjett overskredet",
"it": "Budget superato",
"pt": "Orçamento excedido",
"es": "Presupuesto excedido",
"ar": "تجاوز الميزانية",
"fr": "Budget dépassé",
"tr": "Bütçe aşıldı",
"ja": "予算超過"
},
"CHAT_INTERFACE$AGENT_PAUSED_MESSAGE": {
"en": "Agent has paused.",
"de": "Agent pausiert.",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/agent-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum AgentState {
AWAITING_USER_CONFIRMATION = "awaiting_user_confirmation",
USER_CONFIRMED = "user_confirmed",
USER_REJECTED = "user_rejected",
BUDGET_EXCEEDED = "budget_exceeded",
}

export const RUNTIME_INACTIVE_STATES = [
Expand Down
1 change: 1 addition & 0 deletions openhands/controller/agent_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ async def _react_to_exception(
err_id = 'STATUS$ERROR_LLM_INTERNAL_SERVER_ERROR'
elif isinstance(e, BadRequestError) and 'ExceededBudget' in str(e):
err_id = 'STATUS$ERROR_LLM_OUT_OF_CREDITS'
await self.set_agent_state_to(AgentState.BUDGET_EXCEEDED)
elif isinstance(e, RateLimitError):
await self.set_agent_state_to(AgentState.RATE_LIMITED)
return
Expand Down
4 changes: 4 additions & 0 deletions openhands/core/schema/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ class AgentState(str, Enum):
RATE_LIMITED = 'rate_limited'
"""The agent is rate limited.
"""

BUDGET_EXCEEDED = 'budget_exceeded'
"""The agent is out of credits
"""
Loading