Skip to content

Commit dfcbefb

Browse files
committed
Internal Server Error for UnexpectedModelBehavior
PromptTooLongResponse currently does not represent the actual error. This change logs the underlying exception and responds with a more generic Internal Server Error.
1 parent fda5528 commit dfcbefb

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/utils/agents/query.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,11 @@ def map_pydantic_agent_run_error(
116116
match exc:
117117
case ContentFilterError() as filter_exc:
118118
return InternalServerErrorResponse.query_failed(str(filter_exc))
119-
case IncompleteToolCall() | UnexpectedModelBehavior():
119+
case IncompleteToolCall():
120120
return PromptTooLongResponse(model=model_id)
121+
case UnexpectedModelBehavior():
122+
logger.error("Unexpected model behavior: %s", exc, exc_info=True)
123+
return InternalServerErrorResponse.generic()
121124
case UsageLimitExceeded():
122125
return QuotaExceededResponse.model(model_id)
123126
case ModelHTTPError() as http_exc if is_context_length_error(str(http_exc)):

0 commit comments

Comments
 (0)