Bug in smolagents sandbox silently breaks standard Python unpacking syntax

A bug discovered in the smolagents AI framework causes its custom AST interpreter to reject several standard Python unpacking patterns, including starred assignment, string unpacking, and list-pattern targets. The sandbox's set_value function only handled fixed-size tuple targets, meaning expressions like 'best, *rest = scores' triggered a misleading 'wrong size' error despite being valid Python since PEP 3132 in 2008. Because the error message was inaccurate, AI agents relying on the sandbox entered retry loops, repeatedly re-submitting correct code without resolution. A list-pattern target variant, such as '[a, b] = [1, 2]', failed even more silently by assigning nothing and raising no error at all. The fix involves rewriting the unpacking branch to mirror CPython's own logic, supporting starred targets, all iterables, and both tuple and list assignment patterns.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in