@@ -279,9 +279,11 @@ async def run_agent(
279279 request_data = await request .json ()
280280 agent_request = AgentChatRequest (** request_data )
281281
282- if agent_request .captchaToken :
283- if not await verify_captcha_token (agent_request .captchaToken ):
284- raise HTTPException (status_code = 429 , detail = "Invalid captcha token" )
282+
283+ if not agent_request .captchaToken :
284+ raise HTTPException (status_code = 400 , detail = "Captcha token is required" )
285+ if not await verify_captcha_token (agent_request .captchaToken ):
286+ raise HTTPException (status_code = 429 , detail = "Invalid captcha token" )
285287
286288 # Increment message count, return 429 if limit reached
287289 if not await activity_tracker .increment_message_count (
@@ -318,9 +320,10 @@ async def run_suggestions(
318320 request_data = await request .json ()
319321 agent_request = AgentChatRequest (** request_data )
320322
321- if agent_request .captchaToken :
322- if not await verify_captcha_token (agent_request .captchaToken ):
323- raise HTTPException (status_code = 429 , detail = "Invalid captcha token" )
323+ if not agent_request .captchaToken :
324+ raise HTTPException (status_code = 400 , detail = "Captcha token is required" )
325+ if not await verify_captcha_token (agent_request .captchaToken ):
326+ raise HTTPException (status_code = 429 , detail = "Invalid captcha token" )
324327
325328 portfolio = Portfolio (holdings = [], total_value_usd = 0 )
326329 suggestions = await handle_suggestions_request (
0 commit comments