Skip to content

Commit

Permalink
Clarify warning for missing imports
Browse files Browse the repository at this point in the history
  • Loading branch information
aymeric-roucher committed Jan 6, 2025
1 parent c47ea60 commit 58d25ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/smolagents/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,10 @@ def step(self, log_entry: ActionStep) -> Union[None, Any]:
f"Error: {str(e)}"
)
else:
error_msg = f"Code execution failed: {str(e)}"
error_msg = str(e)
if "Import of " in str(e) and " is not allowed" in str(e):
console.print(
"[bold red]Code execution failed due to an unauthorized import. Consider passing said import under additional_authorized_imports when initializing your CodeAgent."
"[bold red]Warning to user: Code execution failed due to an unauthorized import - Consider passing said import under `additional_authorized_imports` when initializing your CodeAgent."
)
raise AgentExecutionError(error_msg)

Expand Down

0 comments on commit 58d25ac

Please sign in to comment.