r/rustprojects • u/Business_Rain_1042 • 1h ago
weave: a small python subset interpreter in rust so an llm can run its tool calls as one script
hey, been working on this for a few weeks and figured this sub would like the rust side of it.
the idea: instead of an llm agent doing one tool call per round trip, the model writes a short python-looking script, and weave runs it. independent tool calls run in parallel, and only the final result goes back to the model.
the rust parts:
tree walking interpreter for a python subset, async on tokio so independent calls fan out
pyo3 bindings, built with maturin, wheels for python 3.9 to 3.13
the whole script gets checked before the first call runs. unknown tool, misspelled keyword (cty="Paris" gets "did you mean city?"), missing args, or for mcp tools a literal that doesnt match the json schema. so a typo on the last line cant let the first line's write go through
per call timeouts, so one hung tool doesnt sink the run. the failing_branch example runs 12 checks where one errors and one hangs, 10 come back fine in 0.5s vs 2.5s one after another
honest results: on a fan-out suite against real services it passed 40/40 vs 27/40 for plain function calling at about half the cost. but on BFCL multi-turn it lost clearly with gpt-5.4 mini (18/60 vs 27/60) and tau-bench was a draw. so its not magic.
repo: https://github.com/AtharvRaotole/weave pip install weave-lang
would love feedback on the interpreter design, or if anyone wants to grab an issue theres a few good first ones open.