Built-in sandbox SHIM: a numpy-compatible module for the model's Python
sandbox, implemented in PURE Python (stdlib math + random) — NO host/JVM
bridge, NOT a line of Clojure or babashka. numpy is a native C wheel that does
not ship in GraalPy, so agents that reach for import numpy would otherwise
hit ModuleNotFoundError; this extension contributes a :ext/sandbox-shims
entry that env-python/build-agent-context installs into every sandbox
Context (main + every sub_loop fork).
The shim is a correctness-focused SUBSET, not a C-speed numpy: an ndarray
backed by a flat Python list + shape tuple, with broadcasting, reductions,
ufuncs, fancy/boolean/slice indexing, dot/matmul, a linalg submodule
(norm/det/inv/solve/matrix_power/matrix_rank via pure-Python Gaussian
elimination) and a random submodule (stdlib random). Big arrays are slow;
the goal is that agent glue code (np.array, arithmetic, mean/sum, small
linear algebra) just works.
Like shim-requests there are NO :shim/bindings: the shim is a
self-contained Python preamble with zero host callables. It publishes a
numpy module into sys.modules (so import numpy works) and staples it
onto builtins (so numpy.array(...) works with NO import, like json/os).
Built-in sandbox SHIM: a `numpy`-compatible module for the model's Python sandbox, implemented in PURE Python (stdlib math + random) — NO host/JVM bridge, NOT a line of Clojure or babashka. numpy is a native C wheel that does not ship in GraalPy, so agents that reach for `import numpy` would otherwise hit ModuleNotFoundError; this extension contributes a `:ext/sandbox-shims` entry that `env-python/build-agent-context` installs into every sandbox Context (main + every `sub_loop` fork). The shim is a correctness-focused SUBSET, not a C-speed numpy: an `ndarray` backed by a flat Python list + shape tuple, with broadcasting, reductions, ufuncs, fancy/boolean/slice indexing, `dot`/`matmul`, a `linalg` submodule (norm/det/inv/solve/matrix_power/matrix_rank via pure-Python Gaussian elimination) and a `random` submodule (stdlib random). Big arrays are slow; the goal is that agent glue code (`np.array`, arithmetic, `mean`/`sum`, small linear algebra) just works. Like `shim-requests` there are NO `:shim/bindings`: the shim is a self-contained Python preamble with zero host callables. It publishes a `numpy` module into `sys.modules` (so `import numpy` works) and staples it onto builtins (so `numpy.array(...)` works with NO import, like json/os).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |