Edits and changesets
The assistant never writes patch JSON. It sends operations; the library turns them into a changeset the board applies. Code: agent/src/bleep_agent/ops.py, patch.py, catalog.py, sim.py.
The patch and the catalog
The patch is exactly the board's own JSON (nodes, cables, panels; the format board::parse reads), so a snapshot, a changeset, a benchmark fixture and an example preset are the same data. Knob values in it are normalised to 0..1; the library converts to and from real units (Hz, seconds, choice names) with the catalog.
The catalog describes every module type: knobs with range, mapping and choices, jacks with a signal type (audio, control, pitch, gate, trigger, notes), and a small hand-written agent block per module (roles such as filter, typical connections, pitfalls) so "chorus and reverb" resolves to module types without guessing. It is generated from the engine's module registry, with a check (python -m bleep_agent.catalog check) that fails when the file is out of date.
Operations
propose_changes takes a list of operations (a Pydantic discriminated union on op):
| op | Does |
|---|---|
add_module |
Adds a module with knob values in real units; ref gives it a local handle, usable as $ref by later ops of the same call |
remove_module |
Removes a module and its cables (destructive) |
connect, disconnect |
Cables; the target may be an input jack or a knob id, which modulates it with amount as depth |
set_param, set_cable_amount |
Values; a clamped value is reported |
insert_on_cable |
Breaks a cable and puts a module in it; stereo pairs (l/r) are handled together |
rename_module, move_module, set_node_data, set_muted, set_tempo |
The rest |
Adding and wiring happen in one call, so a module never arrives without its cables.
Validation
apply_ops is transactional: either every operation is valid and the patch changes, or an error names the failing operation (op 3: ...) and nothing changes. It checks that:
- the module type and every jack and knob exist (the error lists the real ones),
- cables run from an output to an input and the signal types are compatible,
- there is no duplicate cable,
- values are in range, or are a valid choice name.
The error goes back to the model as a retryable tool error, and the model corrects itself, usually in one more step. This is why a typo in a jack id is cheap while a hallucinated module would be fatal to a design that writes JSON directly.
From operations to a changeset
Valid operations are compiled to primitive operations that the client applies in order:
add_node, remove_node, add_cable, remove_cable, set_param, set_cable_amount,
set_data, set_muted, rename_node, move_node, set_tempo, set_panel, remove_panel
A changeset is {id, summary, ops, lines, destructive}: the primitives, readable diff lines for the chat ("+ Chorus, + Reverb, 2 cables rewired") and a destructive flag. The board applies it as one undo step, so the board's own Cmd/Ctrl+Z is the safety net in both modes. Ids generated by the library follow the board's style and never collide with the snapshot. A changeset id is a hash of its operations, which makes a replayed conversation (the benchmark's cache) identical.
| Mode | A changeset is |
|---|---|
ask |
Shown as a diff with Apply and Reject |
auto |
Applied as it streams in; destructive ones still ask |
The client prefixes a note about applied, rejected or undone changesets to the next user message, so the model knows what became of its proposals.
Why is there no sound: diagnosis without audio
check_audibility answers from a graph model (sim.py), not from DSP. It propagates "does this output carry a signal, and does it move" through the cables by module role, with a held note and the transport running as stimulus, and returns structured findings, each with a code, a severity, the module and jack, and a ready fix. The checks include:
- no Audio Out, or Audio Out not connected, or no path from any source to it,
- a source with no trigger path (a VCA driven by an envelope whose gate has no cable),
- a VCA or mixer gain at zero, a filter cutoff closed with no modulation, a muted module,
- a wrong signal type on a cable, a disconnected required jack.
It is an approximation, so the diagnose skill uses it first and, when it is not conclusive, measures with the live tool probe_signals and walks the path backwards from the output to the first silent point. The same graph model is the benchmark's stand-in for the browser, and what makes a fault-injected diagnose case have a ground truth; see Benchmark and results.
Panels and sequencers
Panels are JSON with sections and controls on a grid. For build_panel the model chooses what goes on the panel and how to group it; the library places the controls. propose_panel is stricter than the model: it refuses to drop a knob that is wired to a control. Sequencer tools validate the step shape (length 1..64, gate, integer pitch, velocity 1..127) and tile a short motif to the requested length with ties for held notes.