Home / Demos / Analog filter design in ngspice
Electronics ngspice 39.3
Analog filter design in ngspice
The agent designs a SPICE netlist for a 4th-order active low-pass filter: ripple ≤ 1 dB up to 1 kHz, at least 40 dB down from 10 kHz, using only E24 resistors and E12 capacitors. The judge simulates it in ngspice, cross-checks it against a closed form (a netlist that runs but is mis-wired fails), re-simulates with a 1 MHz-GBW op-amp model, and runs a ±5 % R / ±10 % C Monte-Carlo.
Measured
≤ 1.0 dB to 1 kHz
≤ −40 dB from 10 kHz
≥ 90 %
≤ 0.5 dB
self-test, ≥ 90 % required
reproduced Independently reproduced: byte-identical media. Numbers from the demo's README and receipt.
Ask your agent
With the sandbox plugin or any agent that can use a sandbox, paste:
Set up a sandbox and solve the demo in `cookbook/spice-filter/` of https://github.com/agent-next/sandbox (clone it first). Run `bash cookbook/spice-filter/judge/setup.sh`, read `cookbook/spice-filter/SPEC.md`, then design the artifact yourself: a SPICE netlist of a low-pass filter with input node `in`, output node `out`, ground `0`, driven by its own `AC 1` source, meeting ripple ≤ 1 dB to 1 kHz and ≤ −40 dB for f ≥ 10 kHz, with every resistor on the E24 and every capacitor on the E12 series, and passing the Monte-Carlo gate. Iterate with `bash cookbook/spice-filter/judge/grade.sh <your-netlist.cir> --json v.json` until it exits 0, then paste the final verdict JSON. Do not edit anything under `judge/`; if you believe the judge is wrong, say so instead of working around it. Kill the sandbox when you are done.Or run it yourself
Creates a sandbox, installs the pinned tools, runs the judge's self-test, grades the known-good example, prints the verdict and kills the sandbox.
pip install "git+https://github.com/agent-next/sandbox#subdirectory=cli"
export SBX_API_KEY=<your key> # from the console
git clone --depth 1 https://github.com/agent-next/sandbox && cd sandbox
python3 cookbook/spice-filter/run.pyNo key? Run the judge on any Debian 12 box
# from cookbook/spice-filter/
bash judge/setup.sh
bash judge/selftest.sh
bash judge/grade.sh examples/good/lpf4sk.cirResults
Why a sandbox
The agent needs ngspice, Python and a scratch filesystem to iterate designs; the graded artifact is one small file it hands back before the sandbox is destroyed.
Measured wall time
| Step | Wall time |
|---|---|
judge/setup.sh (fresh install) | 3.2 s |
judge/selftest.sh (good + 9 mutants + determinism) | 6.8 s |
judge/grade.sh examples/good/lpf4sk.cir | 1.8 s |
Limits, plainly
- Small-signal AC only: no noise, slew, supply or transient behaviour is graded.
- The closed-form cross-check recognises the Sallen-Key cascade shape only and fails closed on any other topology.
- The judge pins ngspice from Debian bookworm and needs sudo once for the install.
Source
Demo folder · SPEC · RECEIPT · REPRODUCE — pinned at ba328e6
Run one yourself
Sign in with GitHub for a free key with 10 sandbox-hours. Every demo above finishes in minutes and kills its sandbox when it is done.

