Repository navigation
Brevi v0.24.2
Every build off the fast typed path now says which path it took and which function to rewrite, in one JSON line an agent can act on. More plain Python stays on the typed path: of 765 agent-written programs, 477 build typed, up from 429. random and path functions work in the sandbox, Python files can use # allow read as a comment, fallback errors are shorter (--traceback for the whole one), and printing tuple(xs) no longer shows a list. Release test on this build (one run): 1.09x Python's cost for Sonnet and 1.06x for Haiku, every task passed, 23 of 24 final programs native for each model.
- Every build says which path it took. For a Python file,
brevi run,buildandcheckprint one JSON line on stderr whenever the file is off the typed fast path:{"path":"dynamic","line":3,"fn":"show","why":"print() of a set shows CPython's hash order, ..."},{"path":"pybridge","why":"numpy run in CPython","py":["numpy"]}or{"path":"cpython","line":2,"fn":"g","why":"Brevi could not build it: unknown function eval()","by":"python3"}.line,fn(andfilein a module) name the code to rewrite to get the typed path back. The typed path stays silent;--explainprints it too and adds the fix, up to five more reasons and why the dynamic build refused a CPython run;BREVI_PATH=1prints the line for every build,BREVI_PATH=0never. The CPython fallback'snote: ran with python3; ...line is replaced by its{"path":"cpython"}line. bench/e2e.py logs each pyb task's final path and adds atypcolumn (tasks on the typed path). - More plain Python stays on the typed fast path. On a corpus of 765 agent-written programs (the saved benchmark solutions and past fallback repros), 429 built typed before and 477 now (372 of the 580 solutions, up from 326), none moved off the typed path, and every moved program with tests prints what python3 prints on them. Loops, comprehensions and prints of a set of strings (or of tuples led by one) build typed: CPython draws string hashes afresh each run, so no order is CPython's own (rustc checks the element type; sets of numbers still go to the dynamic build, which follows CPython's order). A comprehension over a set handed straight to
max,min,sorted,any,all,lenorsetno longer counts as an order-dependent use. A sentinelMISSING = object()used only to mark "no value" (d.get(k, MISSING),if old is MISSING:) is read as None when the program cannot tell the two apart (no other None value reaches it, no truth test on it). Also typed now:[[int(x) for x in row] for row in rows]and other comprehensions inside comprehensions that can fail,d.get(k, {})andd.get(k, [])on JSON objects,t[:2]andt[1:]on tuples, a lambda set inside a loop or if body, anddatetime.date(...)in a function with a local nameddate. - Silent wrong output fixed:
print(tuple(xs)). A tuple made withtuple(...)from a list or iterator is held as a list by the typed build, so printing it (or a list of them) showed[1, 2]instead of(1, 2). Such programs now build over dynamic values. - random, path text and
# allowwork in the sandbox. Under--sandboxand in the MCP tools (sandboxed by default),import random; random.seed(1)gave two confusing errors (unknown method .seed()andunknown name 'random'). random now runs natively there from Brevi's own copy of CPython's generator, so a seeded program draws the same numbers as CPython (seed,random,randint,randrange,choice,choices,shuffle,sample,uniform,gauss,getrandbits,Random); any other random function gives one error naming it and saying it needsallow native. Path text no longer needsallow nativeeither:os.path.join,basename,dirname,split,splitext,normpath,isabs,os.sepandpathlib.PurePath(POSIX rules) run without CPython, while every call that reaches files, processes or the environment (os.listdir,os.environ,os.system,pathlib.Path,os.path.exists,ospassed as a value) is still refused, now by name. New tests in tests/sandbox show each of those stays blocked, and that Brevi's own PurePath has no file access at all. In Python files the allow line can be a comment,# allow read, so the file stays valid Python (the bareallow readstill works and stays the form for.bvfiles), and fixes suggest the comment form. - Shorter fallback output. When
brevi runfalls back to CPython on a sure mistake, it printed the note and then CPython's whole traceback, so the error was read twice. It now prints the note and only the traceback's last line, with where it was raised (NameError: name 'totl' is not defined (main.py line 3)).--tracebackorBREVI_TRACEBACK=1shows the whole traceback; other fallbacks are unchanged.
Prebuilt brevi compiler for Linux, macOS and Windows. brevi still needs rustc on the PATH to build programs. On Linux and macOS, sh install.sh installs rustc if it is missing and picks the right download; on Windows, install Rust with rustup and unzip the .zip. Details: https://brevi-lang.org/docs/install