mirror of
https://github.com/j93es/browser-use-oauth.git
synced 2026-06-04 03:41:52 +09:00
20 lines
No EOL
734 B
Python
20 lines
No EOL
734 B
Python
from lib.browser_use_utils.clean_resources import clean_agent_resources
|
|
|
|
async def run_agent(agent):
|
|
try:
|
|
response = await agent.run()
|
|
final_result = response.final_result()
|
|
|
|
if final_result is None:
|
|
return -1, "최종 결과가 없습니다. 에이전트 실행 실패"
|
|
return 0, final_result
|
|
except Exception as e:
|
|
# API 쿼터 문제인지 확인
|
|
if "ResourceExhausted" in str(e) or "429" in str(e):
|
|
return 1, "API 쿼터 에러로 인한 실패"
|
|
# 일반 에러 처리
|
|
else:
|
|
return 2, "일반 에러로 인한 실패"
|
|
finally:
|
|
await clean_agent_resources(agent)
|
|
print("리소스 정리 완료") |