You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I tried to intentionally tell CodeAgent to output code with syntax error in its tool calling code. It did show the error message, but it omitted the informative error/exception type, i.e. SyntaxError. This is just an illustration, as it could as well be KeyError, NotImplementedError, ImportError, etc.
Code to reproduce the error
fromsmolagents.agentsimportCodeAgentfromsmolagentsimporttool, HfApiModelmodel=HfApiModel("Qwen/Qwen2.5-72B-Instruct")
@tooldefgive_yes(query: str) ->str:
""" Give a yes string as an answer Args: query: any question you have """returnf"yes, {query}"agent=CodeAgent(tools=[give_yes], additional_authorized_imports=["os"], model=model)
query="can you call give_yes, giving the content of os.environ['PWD'] as an input to it, but intentionally made a syntax error, and tell me what the tool says?"print(agent.run(query))
Error logs (if any)
╭───────────────────────────────────────────────────────── New run ─────────────────────────────────────────────────────────╮
│ │
│ can you call give_yes, giving the content of os.environ['PWD'] as an input to it, but intentionally made a syntax error, │
│ and tell me what the tool says? │
│ │
╰─ HfApiModel - Qwen/Qwen2.5-72B-Instruct ──────────────────────────────────────────────────────────────────────────────────╯
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
─ Executing parsed code: ──────────────────────────────────────────────────────────────────────────────────────────────────
give_yes(query os.environ['PWD'])
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Code parsing failed on line 1 due to: SyntaxError
give_yes(query os.environ['PWD'])
^
Error: invalid syntax. Perhaps you forgot a comma? (<unknown>, line 1)
[Step 0: Duration 2.57 seconds| Input tokens: 2,091 | Output tokens: 50]
Expected behavior SyntaxError: invalid syntax. Perhaps you forgot a comma? (<unknown>, line 1)
Packages version:
Name: smolagents
Version: 1.9.2
The text was updated successfully, but these errors were encountered:
Ah, I didn't see the message Code parsing failed on line 1 due to: SyntaxError. Maybe it should be bundled together with the message like in the usual Python console output?
Describe the bug
I tried to intentionally tell CodeAgent to output code with syntax error in its tool calling code. It did show the error message, but it omitted the informative error/exception type, i.e.
SyntaxError
. This is just an illustration, as it could as well beKeyError
,NotImplementedError
,ImportError
, etc.Code to reproduce the error
Error logs (if any)
Expected behavior
SyntaxError: invalid syntax. Perhaps you forgot a comma? (<unknown>, line 1)
Packages version:
The text was updated successfully, but these errors were encountered: