fix: widen actions_taken to list[Any] and improve bot error replies
DispatchResponse declared actions_taken as list[dict] but agents return list[str], causing a 422 on every successful upload. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -117,9 +117,24 @@ def _agent_thread(db: str, uid: int, text: str, att_data: list,
|
||||
'I could not process your request right now.'
|
||||
except _requests.exceptions.Timeout:
|
||||
reply_text = 'The request timed out. Please try again.'
|
||||
except _requests.exceptions.HTTPError as exc:
|
||||
# Try to surface the server-side error detail so the user knows what failed
|
||||
detail = ''
|
||||
try:
|
||||
detail = exc.response.json().get('detail') or ''
|
||||
except Exception:
|
||||
pass
|
||||
_logger.error('Agent HTTP error channel=%s status=%s: %s',
|
||||
channel_id, exc.response.status_code if exc.response else '?', exc)
|
||||
if detail:
|
||||
reply_text = f'The agent returned an error: {detail}'
|
||||
else:
|
||||
reply_text = (f'The agent service returned an unexpected error '
|
||||
f'(HTTP {exc.response.status_code if exc.response else "?"}). '
|
||||
f'Please try again or contact your administrator.')
|
||||
except Exception as exc:
|
||||
_logger.error('Agent thread error channel=%s: %s', channel_id, exc)
|
||||
reply_text = 'I encountered an error. Please try again or contact your administrator.'
|
||||
reply_text = f'I encountered an error: {exc}'
|
||||
|
||||
_post_bot_reply(db, channel_id, bot_partner_id, reply_text)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user