Skip to content

Conversation

SrzStephen
Copy link
Contributor

@SrzStephen SrzStephen commented Jun 1, 2025

As outlined in #1292

Code execution failed at line 'distance_earth_mars = search(query="distance between Earth and Mars")' due to: InterpreterError: Forbidden function evaluation: 'search' is not among the explicitly allowed tools or defined/imported in the preceding code

The prompt is making the agent think that search should be used when HF tools DuckDuckGoSearchTool, GoogleSearchTool, WebSearchTool use web_search.

I've also updated the WikipediaSearchTool prompt to call wikipedia_search instead of wiki since it appears to have a similar issue.

Note: I think the same issue is present in toolcalling_agent.yaml but I'm not 100% sure if this is intentional or not: There are tools that don't exist in this repo referenced in other places.

  Task: "Which city has the highest population , Guangzhou or Shanghai?"

  Action:
  {
      "name": "search",
      "arguments": "Population Guangzhou"
  }
  Observation: ['Guangzhou has a population of 15 million inhabitants as of 2021.']


  Action:
  {
      "name": "search",
      "arguments": "Population Shanghai"
  }
  Observation: '26 million (2019)'

  Action:
  {
    "name": "final_answer",
    "arguments": "Shanghai"
  }

…earch

As outlined in huggingface#1292

```
Code execution failed at line 'distance_earth_mars = search(query="distance between Earth and Mars")' due to: InterpreterError: Forbidden function evaluation: 'search' is not among the explicitly allowed tools or defined/imported in the preceding code
```

The prompt is making the agent think that `search` should be used when Hf tools [DuckDuckGoSearchTool](https://github.com/huggingface/smolagents/blob/522a315c955a8b0649238d835c23353d8ec54434/src/smolagents/default_tools.py#L102), [GoogleSearchTool](https://github.com/huggingface/smolagents/blob/522a315c955a8b0649238d835c23353d8ec54434/src/smolagents/default_tools.py#L127), [WebSearchTool](https://github.com/huggingface/smolagents/blob/522a315c955a8b0649238d835c23353d8ec54434/src/smolagents/default_tools.py#L214) use `web_search`.

I've also updated the [WikipediaSearchTool](https://github.com/huggingface/smolagents/blob/522a315c955a8b0649238d835c23353d8ec54434/src/smolagents/default_tools.py#L410) prompt to call `wikipedia_search` instead of `wiki` since it appears to have a similar issue.
… applied in `code_agent.yaml`

Fixed `code_agent.yaml` to use wiki search instead of wiki search in rules for wikipedia search.

I have left `toolcalling_agent.yaml` alone as I'm not 100% sure whether that has the same issue or whether it was intentional.

```
  Task: "Which city has the highest population , Guangzhou or Shanghai?"

  Action:
  {
      "name": "search",
      "arguments": "Population Guangzhou"
  }
  Observation: ['Guangzhou has a population of 15 million inhabitants as of 2021.']

  Action:
  {
      "name": "search",
      "arguments": "Population Shanghai"
  }
  Observation: '26 million (2019)'

  Action:
  {
    "name": "final_answer",
    "arguments": "Shanghai"
  }
```
@SrzStephen SrzStephen changed the title Bug: Update prompts: search -> web_search and wiki -> wiki_search Fix: Update prompts: search -> web_search and wiki -> wiki_search Jun 1, 2025
Copy link
Member

@albertvillanova albertvillanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I think this should help the LLM avoid confusion.

@albertvillanova albertvillanova changed the title Fix: Update prompts: search -> web_search and wiki -> wiki_search Update prompts to avoid confusion: search -> web_search and wiki -> wiki_search Jun 2, 2025
@albertvillanova albertvillanova merged commit 8c8bf2e into huggingface:main Jun 2, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants