diff --git a/agent.py b/agent.py index f650381..d263e3a 100644 --- a/agent.py +++ b/agent.py @@ -264,6 +264,8 @@ def run_one_iteration(self) -> Literal["COMPLETE", "CONTINUE"]: return "COMPLETE" if not response.candidates: + if response.prompt_feedback and response.prompt_feedback.block_reason == types.BlockReason.SAFETY: + raise ValueError(f"Response was blocked due to safety. Feedback: {response.prompt_feedback}") print("Response has no candidates!") print(response) raise ValueError("Empty response")