{"slug": "arabian-sand-boa-python-interpreter-with-frontier-intelligence-conditional-eval", "title": "Arabian Sand Boa: Python interpreter with frontier intelligence conditional eval", "summary": "Arabian Sand Boa is a Python script that rewrites if/elif conditions at the AST level, sending string conditions to an LLM for evaluation. The tool allows natural-language clauses to control program flow, but sends local variables to the LLM endpoint and may be slow for loops.", "body_md": "Run a Python file where **string if conditions are decided by an LLM**.\n\n`arabian_sand_boa`\n\nis a single, dependency-free script (standard library only).\nIt reads your target file, rewrites every `if`\n\n/`elif`\n\nat the AST level, and runs\nit. When a condition resolves to a **non-empty string**, the string is treated as\na natural-language clause and sent to an LLM along with the variables currently\nin scope; the model's `True`\n\n/`False`\n\nanswer decides which branch runs. Every\nother condition resolves the normal way via `bool()`\n\n.\n\n```\n./arabian_sand_boa <file.py> [args...]          # it's executable\n```\n\n`--debug`\n\n(or `-d`\n\n) prints, to stderr, the exact prompt sent to the LLM and the\nraw reply for each clause it evaluates.\n\nThe target file runs with `__name__ == \"__main__\"`\n\n, so its main block executes.\n\nThe LLM endpoint is configured entirely through environment variables, read lazily — a target that only uses ordinary (non-string) conditions never needs them.\n\n| Variable | Meaning |\n|---|---|\n`BOA_LLM_URL` |\nFull chat-completions endpoint URL |\n`BOA_LLM_API_KEY` |\nBearer token for that endpoint |\n`BOA_LLM_MODEL` |\nModel name to request |\n\nThe endpoint is expected to speak the OpenAI-style chat-completions protocol\n(`POST`\n\na JSON body with `model`\n\nand `messages`\n\n, get back\n`choices[0].message.content`\n\n).\n\nCopy `.example.env`\n\nto `.env`\n\n, fill in your values, and load it:\n\n```\ncp .example.env .env\n# edit .env\nset -a; source .env; set +a\n\npython3 arabian_sand_boa example.py\n```\n\n`.env`\n\nis gitignored; `.example.env`\n\nis the tracked template. If any required\nvariable is missing when an LLM call is needed, the run fails with a clear error\nnaming the missing variable(s).\n\n**Rewrite.** An`ast.NodeTransformer`\n\nreplaces each`if <test>:`\n\nwith`if __if_hook__(<test>, \"<source text of test>\"):`\n\n.**Decide.**`__if_hook__`\n\nevaluates`<test>`\n\n. If it's a non-empty string, the hook gathers the caller's non-dunder local variables and asks the LLM whether the clause holds. Otherwise it returns`bool(<test>)`\n\nand no API call is made.**Parse.** The reply is lower-cased and stripped:`true`\n\n→ take the branch,`false`\n\n→ skip it, anything else → take the branch (cautious default).\n\n**Your local variables leave the machine.** For every string condition, the in-scope (non-dunder) local variables are serialized and sent to the configured LLM endpoint. Do not run this over sensitive data.- An LLM call fires for\n**every executed string condition**, so loops with string clauses are slow and chatty against the endpoint. - Decisions are only as reliable as the model and the wording of your clause, and may vary between runs.\n\nSee `example.py`\n\nfor a runnable showcase mixing natural-language clauses\n(drinking age, admin privileges, account health) with an ordinary boolean\ncondition.", "url": "https://wpnews.pro/news/arabian-sand-boa-python-interpreter-with-frontier-intelligence-conditional-eval", "canonical_source": "https://github.com/hopafoot/arabian-sand-boa", "published_at": "2026-06-24 01:25:27+00:00", "updated_at": "2026-06-24 01:44:21.316931+00:00", "lang": "en", "topics": ["large-language-models", "developer-tools"], "entities": ["Arabian Sand Boa", "OpenAI"], "alternates": {"html": "https://wpnews.pro/news/arabian-sand-boa-python-interpreter-with-frontier-intelligence-conditional-eval", "markdown": "https://wpnews.pro/news/arabian-sand-boa-python-interpreter-with-frontier-intelligence-conditional-eval.md", "text": "https://wpnews.pro/news/arabian-sand-boa-python-interpreter-with-frontier-intelligence-conditional-eval.txt", "jsonld": "https://wpnews.pro/news/arabian-sand-boa-python-interpreter-with-frontier-intelligence-conditional-eval.jsonld"}}