0xPlaygrounds / 0xPlaygrounds/rig

feat: Add a "Code Mode" tool to Rig

Offen
#1,439 12 Kommentare 6 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
feat
Vorherrschende Sprache
Rust
Sterne
8.6k
Forks
959
Ø Merge
4 Std. 32 Min.
Gemergte PRs (30 T.)
117

Beschreibung

- [x] 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](https://boajs.dev/), 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 `this` in 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 `code` field 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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

The issue proposes integrating a JavaScript runtime (Boa) into Rig's tool system. Start by examining the existing tool calling architecture in the codebase. Look for modules related to tool execution, structured outputs, and any existing Rust macro infrastructure. Understanding how to expose a Rust API to JavaScript via Boa is key. 'Done' means a design proposal or prototype that addresses the open questions about integration, async, safety, and ease of use.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, rust
Bereich
ai-infra-agents, backend-api-design, tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.