{"record":{"id":"c393ce30b76f2b20","repo":"huggingface/smolagents","slug":"unsupported-comparison-operator-op","errorCode":null,"errorMessage":"Unsupported comparison operator: {op}","messagePattern":"Unsupported comparison operator: (.+?)","errorType":"exception","errorClass":"InterpreterError","httpStatus":null,"severity":"error","filePath":"src/smolagents/local_python_executor.py","lineNumber":995,"sourceCode":"            current_result = left != right\n        elif op == ast.Lt:\n            current_result = left < right\n        elif op == ast.LtE:\n            current_result = left <= right\n        elif op == ast.Gt:\n            current_result = left > right\n        elif op == ast.GtE:\n            current_result = left >= right\n        elif op == ast.Is:\n            current_result = left is right\n        elif op == ast.IsNot:\n            current_result = left is not right\n        elif op == ast.In:\n            current_result = left in right\n        elif op == ast.NotIn:\n            current_result = left not in right\n        else:\n            raise InterpreterError(f\"Unsupported comparison operator: {op}\")\n\n        if current_result is False:\n            return False\n        result = current_result if i == 0 else (result and current_result)\n        left = right\n    return result\n\n\ndef evaluate_if(\n    if_statement: ast.If,\n    state: dict[str, Any],\n    static_tools: dict[str, Callable],\n    custom_tools: dict[str, Callable],\n    authorized_imports: list[str],\n) -> Any:\n    result = None\n    test_result = evaluate_ast(if_statement.test, state, static_tools, custom_tools, authorized_imports)\n    if test_result:","sourceCodeStart":977,"sourceCodeEnd":1013,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/local_python_executor.py#L977-L1013","documentation":"A comparison chain used a comparator node the interpreter does not handle. It supports Is, IsNot, In, NotIn, Eq, NotEq, Lt/LtE/Gt/GtE — anything else in an ast.Compare triggers this error.","triggerScenarios":"Effectively unreachable with standard Python source (the ast module only produces the supported ops), but can occur with manually constructed or patched AST nodes, or after a library version changes AST node types.","commonSituations":"AST being built programmatically and passed to evaluate_ast; version mismatch between Python's ast node classes and the interpreter's if-elif chain; custom AST transformations injecting exotic operators.","solutions":["If building AST manually, use only standard ast comparison nodes (ast.Eq, ast.Lt, ast.In, etc.)","Re-run with code parsed via ast.parse rather than hand-built nodes","Update smolagents if you're on an old version that misses newly supported operators"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# only build AST via ast.parse on real source, never hand-constructed Compare nodes\nimport ast\ntree = ast.parse(source_text)","typeGuard":null,"tryCatchPattern":"try:\n    evaluate_ast(tree, state, static_tools, custom_tools, authorized_imports)\nexcept InterpreterError as e:\n    if 'Unsupported comparison operator' in str(e):\n        # rebuild tree from source with ast.parse and retry","preventionTips":["Never construct comparison nodes manually","Keep smolagents updated alongside your Python version"],"tags":["python-executor","comparison","ast","smolagents"],"backgroundTag":"unsupported-ast-node","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}