-
Notifications
You must be signed in to change notification settings - Fork 704
Open
Labels
Description
- I have looked for existing issues (including closed) about this
Feature Request
The Rig team has been discussing adding a JavaScript execution tool. This would enable a model to write JavaScript, with a custom API exposing functionality on the Rust side, instead of standard structured JSON tool calling.
Motivation
In our own experiments, we've found supplying tools via an embedded JavaScript runtime (Boa, specifically) to be highly effective, with agents able to focus more clearly, use fewer tokens, and keep the context concise. We think there should be a general, though opinionated, way to do this in Rig.
Proposal
The current architecture is expected to look like:
- You define a Rust API, either a module for stateless APIs, or a type (which becomes
thisin JS) for stateful - We provide a macro which transforms this into boilerplate that exposes this API in a Boa.js JavaScript engine
- The model responds with structured outputs such as
{ code : string, description : string } - The
codefield is passed to the runtime - Code executes and the output is made available to your harness
Some questions remain:
- Tools integration: Is this built into our existing tool system, or just driven by structured outputs?
- Async: Is it worth the complexity? Or are users okay with blocking in their API
- Ease of use vs customization: Which is the priority, or can we manage both?
- Safety: Boa has no network or filesystem access by default, do we provide opt-in escape hatches? And how do we surface the risks to users who enable them?
We would love input on the architecture or open questions above, as well as any use-cases we may not have considered.
Reactions are currently unavailable