huggingface / huggingface/smolagents
Repeatedly getting "Error in code parsing: Your code snippet is invalid"
- Dominant language
- Python
- Stars
- 29.3k
- Forks
- 3k
- Avg merge
- 17m
- Merged PRs (30d)
- 2
Description
I repeatedly get this error when using the Codeagent:
```Error in code parsing:
The code blob is invalid, because the regex pattern ```(?:py|python)?\n(.*?)\n``` was not found in code_blob ...
```
I have tried to emphasize proper code block formatting in the agent.run() argument, to no avail.
The error occurs while using GPT-4o and Sonnet 3.5.
How can I fix this or at least improve realiability?
Thanks for any help in this regard!
Contributor guide
Research direction
No source file or test is named in the report. Start by reproducing the failure with agent.run() using GPT-4o or Sonnet 3.5, then trace where the reported code-block regex is applied. Done means reliably handling the returned code or providing a clear, actionable parsing failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100