huggingface/smolagents · warning · InterpreterError
Operation {type(expression.op).__name__} is not supported.
Error message
Operation {type(expression.op).__name__} is not supported. What it means
evaluate_augassign implements Add, Sub, Mult, Div, FloorDiv, Mod, Pow, BitOr, BitXor, BitAnd, LShift, RShift; any other operator node in an augmented assignment raises InterpreterError naming the op class. Standard Python cannot produce others, so this is an exhaustiveness guard.
Source
Thrown at src/smolagents/local_python_executor.py:695
current_value /= value_to_add
elif isinstance(expression.op, ast.Mod):
current_value %= value_to_add
elif isinstance(expression.op, ast.Pow):
current_value **= value_to_add
elif isinstance(expression.op, ast.FloorDiv):
current_value //= value_to_add
elif isinstance(expression.op, ast.BitAnd):
current_value &= value_to_add
elif isinstance(expression.op, ast.BitOr):
current_value |= value_to_add
elif isinstance(expression.op, ast.BitXor):
current_value ^= value_to_add
elif isinstance(expression.op, ast.LShift):
current_value <<= value_to_add
elif isinstance(expression.op, ast.RShift):
current_value >>= value_to_add
else:
raise InterpreterError(f"Operation {type(expression.op).__name__} is not supported.")
# Update the state: current_value has been updated in-place
set_value(
expression.target,
current_value,
state,
static_tools,
custom_tools,
authorized_imports,
)
return current_value
def evaluate_boolop(
node: ast.BoolOp,
state: dict[str, Any],
static_tools: dict[str, Callable],View on GitHub (pinned to 30bb116109)
Solutions
- Use one of the supported compound operators in executed code
- Expand the operation manually (x = x <op> y) using a supported form
- Upgrade smolagents if a newer release added the operator
Defensive patterns
Strategy: validation
Validate before calling
import ast
SUPPORTED_OPS = (ast.Add, ast.Sub, ast.Mult, ast.Div, ast.FloorDiv, ast.Mod, ast.Pow,
ast.BitOr, ast.BitXor, ast.BitAnd, ast.LShift, ast.RShift)
for node in ast.walk(ast.parse(code)):
if isinstance(node, ast.AugAssign) and not isinstance(node.op, SUPPORTED_OPS):
raise ValueError(f'unsupported augmented operator: {type(node.op).__name__}') Try / catch
from smolagents.local_python_executor import InterpreterError
try:
evaluate_python(code)
except InterpreterError as e:
if 'is not supported' in str(e) and 'Operation' in str(e):
raise NotImplementedError(str(e)) from e Prevention
- Stick to the standard compound operators in executed code
- Expand exotic compound ops into plain assignments
- Upgrade smolagents when adopting new Python grammar features
When it happens
Trigger: Only reachable with a programmatically constructed AST containing an exotic ast.operator in an AugAssign, or a future grammar change; normal source code always hits one of the implemented branches.
Common situations: Hand-built ASTs fed to evaluate_ast; version skew after a new Python release introduces an operator before smolagents adds support.
Related errors
- AugAssign not supported for {type(target)} targets.
- Unary operation {expression.op.__class__.__name__} is not su
- Unsupported AnnAssign target in class body: {type(target).__
- Cannot add non-list value {value_to_add} to a list.
- This is not a correct function: {call.func}).
AI-assisted analysis of huggingface/smolagents@30bb116109 (2026-08-28).
Data as JSON: /api/errors/192486c2a6e2caf6.
Report an issue: GitHub.