At a glance Topic Detail What it adds One calendar for each user, inside LocalAI. A chat or a saved agent reads and changes events. There is no account to connect. Needs Nothing. There’s no account to connect. Ask a chat or a saved agent “what is on Thursday?” or “add dinner with Sam at 8” and it reads or changes your calendar. Install it and ask. There’s nothing to connect. Writes run at once, with no confirmation card.
At a glance Topic Detail What it adds One address book for each user, inside LocalAI. A chat or a saved agent looks up and keeps contacts. There is no account to connect. Needs Nothing. There’s no account to connect. Ask a chat or a saved agent “what is Marco’s number?” or “add Anna, anna@example.org” and it reads or changes your address book. Install it and ask. There’s nothing to connect. Writes run at once, with no confirmation card.
If you need exact control of the layout, Sandbox can build the same files with Python. You can install either one without the other. See Sandbox: run Python on your files.
LocalAI docs > Add-ons > Catalogue > Work tools
Sandbox: run Python on your files
At a glance
Topic
Detail
What it adds
A bash tool that runs commands and code in an isolated sandbox with your files mounted. It makes charts, converts files and runs scripts.
Needs
A Linux host that can run KVM or gVisor, or a Mac with Apple silicon, and the chats and their files turned on.
Ask a chat to make a bar chart from sales.csv. It runs the code in an isolated sandbox with your files mounted and saves the PNG in your files. Sandbox can also convert a file or run a script. It runs on Linux, and on macOS with Apple silicon.
What you need
An administrator who installs the add-on. See the user guide.
A host that can run an isolated backend. The add-on tries KVM (Cloud Hypervisor) first, then gVisor. KVM needs /dev/kvm. gVisor needs runsc and permission to create a user namespace. If neither works, no command runs, and the chat says so.
The chats and their files turned on, because the sandbox works on your files.
Turn it on for a chat
Open the Tools menu of the chat.
Switch Sandbox on.
When it is on, the bash tool of the chat runs in the sandbox. Without it, a chat can run commands on the server only if an administrator allows it, and then nothing isolates them. See Running commands.
How it works
Each user and chat has its own sandbox. The model cannot name another user or chat.
Your files are mounted under /workspace/home. Each command starts there.
After each command, what changed is saved to your files as one change. You can undo it in the history of Files. If someone else changed the same file, their version stays and the sandbox version is saved as a copy.
A sandbox is suspended after 10 minutes without use.
An answer is cut at 64 KiB. A command stops after 120 seconds by default, and after 28 minutes at most.
Network
A sandbox has no network device. HTTP and HTTPS go through a proxy that asks LocalAI for each connection. The Network row in the Tools menu has three choices: Off, Custom (the package registries and the domains an administrator added) and All public sites. An administrator sets the most a chat can choose. On a fresh installation of the official Sandbox, new chats start at All public sites: commands can download from public sites and send data to them. To disconnect just one chat, choose Off in its Tools menu. That choice stays with the chat when you reopen it; other chats keep their own settings. Upgrading an existing installation does not widen its policy.
When a command asks for a host that the chat does not allow but the limit allows, the chat shows a card. Choose Allow once, Allow for this chat or Deny. See Network of the Sandbox commands.
What is installed
The base profile has Python with pandas, matplotlib, openpyxl, python-docx, python-pptx, pypdf and Pillow, and tools such as jq, ripgrep, sqlite3, zip, git and curl. The media profile adds ffmpeg, sox and ImageMagick. The opt-in office profile adds LibreOffice Impress, Writer and Calc, so a presentation or a document can be rendered to images and a workbook recalculated. With the media profile, the built-in assemble-media skill can join, trim and subtitle clips and build short videos with ffmpeg (a title card, a slideshow) as MP4. Look at the result before you use it. You pick the profile in the Tools menu, unless an administrator limits the choice. Programs cannot be installed with apt. See Sandbox profiles.
Troubleshooting
You see
Do this
The chat says it cannot run commands
Open the Sandbox page. It names the backend that runs, or why none works. An administrator sees the reason for each backend.
gVisor fails with cannot read client sync file
The host needs an AppArmor profile that allows user namespaces, and a container that may create them.
pip install fails
The network is Off. Ask an administrator to raise the most a chat can choose.
Set up the Sandbox add-on: where it runs commands, which profiles it offers, what its network rules are, and how it is packaged and upgraded. For what the Sandbox is for and how a chat uses it, see Sandbox.
Sandbox
The Sandbox add-on lets a chat run commands and code in isolation. It has one tool for the model, the action tool bash, which replaces the chat’s built-in bash ("shadows": "bash"), so a chat with the Sandbox sees one bash and it runs isolated. The model reads and changes files with the chat’s own file tools (read_file, write_file, edit_file, list_files, search_files and the others; see Chats): they work on the same files, so a script written with write_file runs with bash at once, and what bash writes is in the user’s files after the call. bash runs inside an isolated sandbox of the user and the chat, with the user’s files mounted under /workspace/home. Each call, and each background job, starts in the chat’s work folder (/workspace/home/Chats/<chat>/work, made before the call) and gets its path as $WORK; a chat with no work folder yet starts in /workspace/home. The description of bash tells the model to use $WORK or relative paths, to quote every path with double quotes, and never to type out a name with spaces or non-ASCII characters. The skill folders are not mounted in the sandbox. User-written scripts must be saved in the home with the file tools before execution. The status tool keeps its add-on name (addon__sandbox__status). Without the Sandbox, or with it off or unable to run, a chat may still run commands on the server itself, without isolation, when an administrator allows it; see Commands on this machine.
Sandbox also owns the docx, pptx, pdf, and xlsx Python/Paper procedures, references, and applicable license notices.
They require the selected Sandbox provider to offer usable isolated commands, with explicit chat or agent grants.
Their packaged skill trees contain text only; executable PDF helpers belong to the guest image.
Invoke /usr/local/lib/localai/document-skills/pdf/content_qa.py and
/usr/local/lib/localai/document-skills/pdf/verify_pdf.py with python3 through Sandbox bash.
No host skill-folder mount is required. Dependency pins remain part of the guest image.
Simple Office keeps its own tool-based procedures and needs no exec grant.
An older package of the add-on also served read, write, edit, glob and grep. They are gone: reinstall the package to drop them. A chat’s switch for the add-on is kept by add-on ID, so nothing a chat stored changes.
One sandbox per user and chat. The key is the pair of the user and the conversation. The user comes from the host. Nobody else reaches the sandbox, and the model cannot name another user or chat.
Changes are one change set. After every call the add-on commits what the code changed, as one change set in the history of the user’s files, so it can be undone there. If someone else changed the same file meanwhile, their version stays and the sandbox’s version is saved as a copy; the answer names the file and the copy. A file written outside /workspace/home (where bash starts) is not saved, and the answer names it too. In a chat whose agent works in one folder, /workspace/home is that folder (read only when the agent can only read it), and the chat’s own folder is at /workspace/chat, where files are saved as well; nothing else of the user’s files is in the sandbox. The change set belongs to the chat that ran the command, so the chat lists the files it saved (see Files that a command saved). A file change by someone else makes the sandbox rebuild its view of the files before the next call.
Limits. At most 4 sandboxes for a user (the oldest idle one gives way to a new one) and 16 in all. When the 16 are used, the oldest suspended sandbox of any user gives way to a new one, so sleeping sandboxes never keep a user out; a call is refused with a busy answer only when every sandbox is running. A sandbox that is idle for 10 minutes is suspended and wakes on the next call. A sandbox is removed 24 hours after it was made. An add-on restart removes every sandbox it left, suspended ones too. When the add-on stops (it is disabled, or the server shuts down) it first stops all its sandboxes, for at most 8 seconds. The supervisor waits for that before it kills the add-on process; a server that is killed with SIGKILL cannot do this, and the next start removes what was left. When a suspended sandbox is removed, the host backend also stops the processes it left running.
Background jobs. The add-on runs the jobs of the chat’s job tool (see Execution provider and status payload) in the chat’s sandbox, in the add-on process. A job’s output (stdout and stderr together, the last 256 KiB, with absolute byte offsets) and its exit status come from the process, not from any connection of the host, so they stay when the call that started the job returns. While a job runs, its sandbox is not given way to another chat, not suspended, not refreshed and not removed at its age. Input goes to the job’s standard input; a call waits at most 5 seconds for the job to read it. A kill sends SIGTERM (or SIGINT) to the job’s process group and SIGKILL 10 seconds later; a job ends after 2 hours the same way. When a job ends, what it wrote is committed as one change set (Job job-3: build) before the sandbox is let go; a file it writes is also in the next bash call’s change set. At most 32 jobs run in the add-on process; the host keeps the limits per chat and per user. A finished job stays readable for 30 minutes, at most 16 per chat. An add-on restart ends every job: the host reads the jobs as gone. A call that must make the sandbox again (a new profile, agent folder or mode) ends the chat’s jobs first and says so at the top of its output.
The network of a job. While no call of the chat runs, the proxy lets a connection through under the operation of the oldest live job of the sandbox (the proxy cannot tell which process opened it; during a call, every connection counts against the call). Each job has its own 64 MiB up and 4 GiB down. A host that the chat’s preset or an always-allowed rule allows passes. A host that needs the person’s yes is blocked, since nobody is there to answer a card: the job’s output gets Blocked by LocalAI: host:port needs the user’s approval, and nobody can be asked while no turn of this chat runs (a background job), and the audit line has the reason unattended. With neither a call nor a job, every connection is refused as before.
Output. A tool answer is cut at 64 KiB, and a bash call stops after its timeout (120 seconds by default, 28 minutes at most, so the answer is back before the 30-minute limit of an action call).
Without a backend. When the host has no way to run sandboxes, nothing runs. A chat is not offered the Sandbox tools then: it gets one stand-in tool that tells the model why, so the model answers that it cannot run code instead of trying. Without the add-on, or with it switched off for a chat, the chat’s model is told that it cannot run commands, and the chat’s Tools menu says so to the user; see Running commands. A tool that is called anyway answers “This host cannot run commands.” The same happens when the Files workspace is off, because a sandbox needs the user’s files.
Where you see the state. The Sandbox page tells every user which backend runs the code, or that no backend works, or, while the host backend is in use, that commands run directly on this machine with no isolation. An administrator also sees, on that page and in Settings, the reason each backend does not work and what to do. An administrator can choose the host backend there: the page shows the warning that commands then run on this machine without isolation, and asks for the typed confirmation before it saves. A user who is not an administrator is told that only an administrator can change this.
Undo. Each bash call that changes files is one change set in the history of the user’s files (Files, History), and it is undone there, one call at a time. A whole turn is not one change set: the sandbox runs in the add-on process and the Files service commits each write of a tool on its own. The file tools of the chat itself work the same way, with an Undo note under the call.
Shared code. The Host backend, the manager that keeps one sandbox per user and chat, and bash live in core/services/studio/sandbox (host, runner). The add-on runs them over its host operations; the chats’ built-in bash runs the same code over the workspace store directly.
Sandbox backends and settings
The add-on runs commands in one of these backends, chosen by an administrator on the Settings tab of the Sandbox details on the Add-ons page (the Sandbox page links to it):
Choice
What it is
Automatic
KVM (Cloud Hypervisor) when the host has it, then gVisor, then a macOS virtual machine (on a Mac with Apple silicon), otherwise nothing. It never picks the host backend, not even as a last resort.
gVisor
runsc with user namespaces. Needs runsc (the package carries it), taskset, and on Ubuntu 24.04 and later an AppArmor profile (the package carries gvisor-profile, which prints it).
KVM
Cloud Hypervisor with virtiofsd, mke2fs, debugfs and /dev/kvm. The package carries Cloud Hypervisor and, on amd64, virtiofsd. bwrap is used when present and not in a container.
macOS virtual machine (vz)
One Linux VM for each chat, run by the Virtualization.framework of macOS. Needs a Mac with Apple silicon and the add-on package for macOS, whose executable carries the virtualization entitlement. The Settings tab shows it only on a Mac, or when it is the saved choice.
Off
No sandbox. Every tool answers that the host cannot run commands.
Host
Runs commands on the host as the user LocalAI runs as, with no isolation.
What the Sandbox needs to run isolated
The Sandbox reports a backend as isolated or as host (see
Execution provider and status payload).
Only gVisor, KVM and the macOS virtual machine report isolated. The host backend runs the command as a
normal process of the user LocalAI runs as. No kernel boundary separates it from
the rest of the machine, so it is never isolated.
Document skills. The docx, xlsx and pdf skills of the Sandbox are offered
only when the Sandbox reports an isolated backend. With the host backend, with
Off, or when no backend works, the chat does not get them.
gVisor. The add-on starts runsc with --network=none, a root file system in
memory (--overlay2=root:memory), --directfs=false and --ignore-cgroups. It
sets no --platform flag, so runsc uses its default platform and not the KVM
platform. gVisor needs no /dev/kvm, no cgroup and no extra capability. It needs
a non-root user, runsc and taskset, and permission to create a user namespace:
the container seccomp profile and, on Ubuntu 24.04 and later, AppArmor must allow
it. The add-on checks this at start with a small test sandbox.
KVM. Cloud Hypervisor needs /dev/kvm for the user LocalAI runs as. Pass the
device to the owner container only when you choose or expect this backend.
macOS virtual machine. The add-on runs each sandbox as a VM of Apple’s
Virtualization.framework, with the same guest image, kernel and guest agent as
KVM, so the guest has a kernel of its own and no network device. It needs a Mac
with Apple silicon, the linux/arm64 variant of the guest image, and the
com.apple.security.virtualization entitlement on the add-on executable (the
macOS package is signed ad hoc with it). The add-on needs no other program: it
converts the image and reads and makes the disk images in its own code. The
limits of a sandbox become the CPU count and the memory of the VM, within what
the Mac allows. Two differences from KVM matter. First, the VMs belong to the
add-on process: when the add-on stops or crashes, every VM stops with it, and
the next start removes the sandboxes it left. Second, a sleeping sandbox keeps
its files but not its running programs: macOS does not let the add-on save the
memory of a VM, so a sandbox that sleeps after 10 minutes of idle time (see
Limits above) wakes with a fresh guest over the same files. A command or a
background job that was still running in it is gone, as after a refresh. A
sandbox that runs a background job does not sleep.
The Mac needs no setting and no manual download for the guest image: the
add-on pulls the linux/arm64 image of each profile when it prepares that profile, with the
progress shown in the status of the profile, and keeps it in its data
folder. The base image is about 220 MB to download and needs about 0.8 GB
of disk once converted; media is about 370 MB and 1.1 GB; office is about 365 MB and 1.4 GB. The first sandbox
of a profile also converts the image, which takes a few seconds. After that a
sandbox is ready in under a second.
Automatic. The add-on tries KVM, then gVisor, then the macOS virtual machine. If
/dev/kvm is missing, it uses gVisor, so an owner container without /dev/kvm
still has an isolated sandbox. On a Mac the first two are not available, so it uses
the macOS virtual machine.
When the owner runs in a container, the container that runs the add-on must meet
these needs. In a split deployment that container is the owner, not the frontends.
The network limit and the presets (Off, Custom, Allow all) apply to
the commands of the Sandbox because every connection goes through its proxy, which
asks the host with egress.check. On current master, the host shows the limit as
applied to an add-on’s commands only when the provider reports that it enforces it.
A provider that only reports isolation does not count. This behavior can change in a
later release.
The Settings tab lists the backends of the host, each with its state (in use, ready or unavailable); the reason a backend does not work is under Details. When gVisor fails with exit status 128 and cannot read client sync file, the row also says that gVisor needs an AppArmor profile that allows user namespaces and a container that may create them, and links to The Sandbox in the LocalAI container. The add-on asks for the network-policy, tool-providers and sandbox-profileshost controls, so the same tab also holds the sandbox profile policy, the network of the Sandbox commands (the limit, the preset of a new chat, the ports, the extra registries, the always allowed hosts, private networks, the audit retention and the audit) and the bash row of Settings > Tools, and saves them like the Settings page. An explicit choice is never replaced by another when it does not work: the tools say they cannot run.
The Host backend is for a machine that can run neither of the others. It is not available when the add-on runs in WSL 2 for LocalAI on Windows. Choosing it takes two steps. The page shows a plain warning and asks the administrator to type the sentence I understand that commands run on this host without isolation. The add-on then saves the choice. The confirmation is forgotten when another backend is chosen. The backend refuses to start when LocalAI runs as root. Every command is logged with the name of the chat user, in the LocalAI log with the prefix [sandbox] (LocalAI writes everything an add-on prints to its output or error into its own log, one line at a time, cut at 4096 bytes), and the Settings tab of the Sandbox details (for administrators) shows a notice for as long as the host backend is the one in use. The model sees it in the answer of the status tool. Treat the machine as one that code can harm.
The choice is kept in the add-on’s data directory. Changing it removes the running sandboxes; what they did is already in the users’ files.
The guest image, runsc and the KVM programs are not part of the add-on’s source. A release sets main.guestImage (the image of the base profile, by digest) at build time. It sets main.profileImages (media=<ref>,office=<ref>) for the images of the media and office profiles. A profile without an image is not offered by that release. The checksums of the runsc and of the Cloud Hypervisor and virtiofsd it was tested with are compiled into the add-on (runscPins and kvmPins in addons/sandbox/cmd/sandbox), and tests keep them equal to package/runsc.json and package/kvm.json. A build without a guest image reports that on the page, and only the host backend can run.
Sandbox profiles
A profile is an environment a sandbox can run in: a name, what it is for, the limits of one sandbox (CPUs, memory, disk) and the programs it has. The Sandbox add-on declares its profiles in its manifest, in the execution.profiles list of the bash tool. Each profile it declares has an image the release built and pinned by digest. An administrator can add more with images of their own (see Custom profiles); users and models cannot. The release ships these:
Profile
For
Programs
CPUs
Memory
Disk
base
Python, documents, PDF and the usual command-line tools.
base is the fallback and is always allowed. The model is told the profile its chat runs, the programs it has and the programs the other profiles add, in the prompt of each turn, and the description of bash names the profile. The text is built from the manifest, so it never differs from the image. The command line runs as an unprivileged user and apt is blocked by the proxy, so nothing can be installed from inside the guest with a system package manager. pip can install Python packages within the chat’s network setting (see Network access). Adding a program means a new guest image. The build of each image fails when a program of its profile is missing or does not start (addons/sandbox/images/guest/check-tools.sh <profile> reads the checks from the manifest).
The office profile. It is base plus LibreOffice Impress, Writer and Calc (no Java) and the fonts DejaVu, Liberation, Carlito and Caladea, so a presentation or a document can be rendered to a PDF and to images and looked at, and a workbook can be recalculated. Carlito and Caladea have the metrics of Calibri and Cambria, so line breaks match Office. It is opt-in: it is not the default, it is not part of media, and it needs no policy entry (with no policy every user may use it). The pptx, docx and xlsx skills tell the model to switch to it before it builds a file, and give it helpers, which every profile has in /usr/local/lib/localai/document-skills/<format>/: pptx/pptx_guard.py, which checks the sizes, the place and the text fit of the shapes with pure Python; render.sh in each of the three folders, which renders the slides or pages to PNG files with a private LibreOffice profile directory; and xlsx/recalc.sh, which recalculates a workbook and saves a copy with the cached values (openpyxl.oracle.recalc does the same and keeps the original package). A sandbox that runs the profile reserves 2 CPUs, 4 GiB of memory and 20 GiB of disk. Rendering a 10-slide deck, rendering a 20-page document and recalculating a workbook each used under 200 MiB, so a host that needs the room can cap memory_mib far lower.
matplotlib draws charts without a display: it writes PNG and SVG files, and the model can save them in the user’s files. Its font cache is kept in /tmp.
Choosing a profile. The profile of a chat is the first of these that exists and that the user may use:
The profile the person picked in the chat. The picker sits next to the network switcher in the Tools menu of the chat.
The profile of the saved agent of the chat (sandbox_profile). Unattended runs of an agent (triggers, jobs, connectors) use it too.
The default profile of the administrator (default of the policy below), then media, then base. With media as the default, each sandbox reserves the limits of media (2 CPUs, 4 GiB of memory, 20 GiB of disk); an administrator who wants the smaller base sets it as the default.
Switching the profile restarts the sandbox at the next command. The user’s files stay. Running processes and installed packages are lost, and the picker says so before you switch. The model can switch too with one tool, sandbox_profile: the action list shows the profiles with their programs, and the action use switches. It is in the Run commands group of the chat and follows the rules of the picker: the user’s own chat and the policy of the administrator. A skill can name the profile it wants with the frontmatter field sandbox: media (see Chats). It is a hint: the model is told, may offer the switch and never switches without the person’s yes.
Policy. The administrator sets the policy on the Settings tab of the add-on (the owner host setting sandbox_profiles, with the same owner rules as the network settings). Everything is open by default: with no policy every user may use every profile.
Key
Meaning
default
The profile a new chat gets. Empty: media, or base when the add-on has no media profile.
access
For a profile, the roles (admin, user) and the users who may use it. A profile that is not listed, or has no roles and no users, is open to everyone.
memory_mib, disk_mib
The most memory and disk one sandbox may have, whatever the profile asks. 0 is no cap.
pin_previous
The profiles that run their previous image. See below.
Images. When the Sandbox add-on starts, it prepares the default image in the background. Selecting an optional profile starts its download without running a command. Opening the picker does not start a download. If a command needs an image that is not ready yet, it shares the download. The picker and the waiting tool call show progress (for example, “Preparing the Media image, 40%”). Ordinary chat does not wait. After an add-on upgrade, the add-on pulls the new image of each profile this host used before in the background, so the first command after the upgrade does not wait. A chat keeps its sandbox, and its image, until the sandbox restarts. The picker then shows that a newer image is available. The add-on keeps the current and the previous image of each profile and deletes the older ones, except an image that a running sandbox still uses. If a new image breaks something, an administrator can add the profile to pin_previous: new sandboxes of the profile then start from the previous image.
If a profile is missing in the release, or its image cannot be pulled, the command runs in base. The output of the command says so (“The media sandbox profile is not available (…), so this command ran in the base profile”), and the picker shows the same notice. The add-on never runs a command in a different profile without saying so. A failed pull is not retried for five minutes, so a broken registry does not stall every command. The images are kept on each machine that runs the add-on: in a cluster every node pulls its own, while the choice of the chat and the policy are shared.
API.GET and PUT /api/chats/{id}/sandbox-profile read and set the profile of a chat, GET /api/chats/sandbox-profiles lists the profiles for a saved agent, and GET /api/chats/admin/sandbox-profiles is the administrator’s view with the state of the images. There custom marks a custom profile and custom_supported says that the add-on takes them. POST /api/chats/admin/sandbox-profiles/{profile}/prepare (administrators) prepares the image of a custom profile now: it answers 202 and the view shows how it went. It takes a profile ID only. A shipped or unknown ID is 400; 409 means that the add-on takes no custom profiles, or that its backend cannot run one. The real error of a custom image that failed is shown only in this administrator view. Chats, the model and users read only its image could not be prepared, also in the chat of an administrator. The Sandbox gives the real error only for the hostImageErrors argument of its status read, which the server sends for this view; /api/addons/dispatch and /api/addons/relay refuse a request that carries it. With an older server or add-on the error can stay hidden.
Custom profiles
An administrator can add up to 5 profiles of their own, each with an image that has the toolchain their users need. A custom profile appears after the shipped ones in the chat picker, the profile of a saved agent, the sandbox_profile tool and the note for the model, and the policy above applies to it the same way: access, memory_mib and disk_mib. With no access entry every user may use it. pin_previous does nothing for a custom profile, which has no previous image: to go back, put the old digest in image.
In the Settings tab. Under Custom profiles, select Add profile and fill in the fields. Write the programs of the image as one list separated by commas. A new profile appears in the list of profiles at once, so you can limit who may use it before you save. One Save writes the profiles and the policy together. A saved profile keeps its ID. It shows the state of its image, the error when the image could not be prepared, and Prepare now. A backend that runs no images shows the saved profiles as not offered. With an add-on that does not take custom profiles, the tab asks you to update it.
The list is the owner host setting sandbox_custom_profiles. A change replaces the whole list, and [] removes it. Every key of an entry is required:
Key
Meaning and limit
id
Lower case letters, digits and -, starting with a letter, at most 32 characters. Not base, media or office, and not repeated.
title, description
One line of plain text, at most 40 and 200 characters.
image
A registry image by digest (name@sha256:...), at most 512 characters. A tag is refused.
cpus
0 (the provider’s default) to 64.
memory_mib
0 (the provider’s default) or 256 to 262144.
disk_mib
0 (the provider’s default) or 64 to 1048576.
tools
At most 24 tool names that the image adds to those of base, each at most 40 characters, not repeated. It can be empty.
The picker, the note for the model and the results of sandbox_profile do not show the image reference. In the error text of a failed image it reads “the image”.
Requirements of the image.
It is built FROM the base guest image of a Sandbox release. Other images are not supported.
It is for linux and the CPU architecture of the machine that runs the add-on.
It keeps the user agent (uid 1000) with the home /home/agent, and bash.
It is in a registry that allows an anonymous pull. LocalAI uses no registry login, and a refused pull says so.
On the gVisor backend, the unpacked files of the image can be at most 16 GiB.
The programs you name in tools are not checked. The model is told they are there.
The host backend runs no images, and off runs no commands. While the add-on uses one of them, custom profiles are not offered, and the list is kept. If the server cannot tell which backend runs, it offers them, and a command that cannot run one runs in base and says so.
Build one. The base image of a release has the tag of the release, for example quay.io/go-skynet/sandbox-guest:v<version>. Read its digest with:
This example adds Go. We have not built it against a published guest image, so check the result before you rely on it:
# Use the digest of the base guest image of your release.FROMquay.io/go-skynet/sandbox-guest@sha256:<digest># The image sends apt to the proxy of a running sandbox, which a build does# not have: DIRECT turns the proxy off for these two commands.RUN apt-get -o Acquire::http::Proxy=DIRECT -o Acquire::https::Proxy=DIRECT update \
&& apt-get -o Acquire::http::Proxy=DIRECT -o Acquire::https::Proxy=DIRECT install -y --no-install-recommends golang \
&& rm -rf /var/lib/apt/lists/*
Other tools that download during a build may read the proxy variables of the image (HTTP_PROXY, HTTPS_PROXY and their lower case forms): unset them in that RUN. Do not change them with ENV, because a running sandbox needs them. Push the image and put its reference by digest in image.
Preparation and upgrades. Choosing the profile in a chat starts the download, and so does the first command that needs it. Every machine that runs the add-on keeps its own cache and pulls for itself; the add-on does not pull custom profiles in the background after an upgrade. When a custom image is prepared, the guest agent, the kernel and /usr/local/lib/localai (the document skill helpers) are taken from the base image of the installed release, so an upgrade prepares the image again. Your packages, Python libraries and proxy settings stay as you built them.
Failure and removal. If the image cannot be prepared, commands run in base and say so; an older prepared copy is not run. A chat or an agent that names a removed profile gets the profile it would get for an unknown one. The add-on learns of a removed or changed profile at the next command or preparation that reaches it, and then deletes the old image once no sandbox runs it.
Shared state. The list is part of the owner’s host policy: every frontend reads it from the owner each time it needs it, and only an administrator can change it. One change can set both sandbox_custom_profiles and the access rules in sandbox_profiles. When a frontend cannot read the list, it offers no custom profile, commands run in base, and the chat shows base with the reason.
Upgrade first. This release of the Sandbox needs a LocalAI with add-on feature level 22: an older LocalAI refuses to install it. When you run several frontends, upgrade every one of them before you first set sandbox_custom_profiles. A frontend that is not yet upgraded cannot read the owner’s host policy once the key is set, so its network rules for commands, its tool provider pins and its sandbox profile policy fail closed.
A LocalAI older than the release that added this key cannot read the host settings document once the key is set. Setting the list to [] does not undo this: the document also keeps the earlier states of the policy, for the replay of repeated writes. If you may need to downgrade, copy the host settings document before you first set this key. Restoring that copy also reverts every other owner setting changed since the copy.
Network access
The guest of a sandbox has no network device: no NIC, no TAP device and no user-mode network stack. A command reaches the network only through one proxy, on guest port 3128, which the guest image sets in HTTP_PROXY, HTTPS_PROXY, pip, apt, git, npm and GOPROXY. The guest agent forwards each connection to that port to the add-on, over vsock (KVM) or a Unix socket (gVisor), and the add-on’s proxy asks LocalAI about each connection with the host operation egress.check. LocalAI decides; the add-on dials. The proxy never decrypts TLS and holds no certificate the guest trusts.
The guest image has curl, git, pip and the CA certificates, and all of them use the proxy (the programs of each profile are under Sandbox profiles). The model is told so at each turn, with the chat’s preset. To read or search web pages it is told to prefer web_fetch and web_search when the chat has them (the built-in ones or the Web add-on’s), and to use curl for APIs, downloads and installs. With the network off, the note says that nothing is reachable.
Commands that run on this machine (the host backend, or the chats’ built-in bash) have the network of the server: none of this applies to them, and the settings say so.
On a fresh installation of the official Sandbox, both the limit and the new-chat preset start at Allow all. For example, curl https://example.com works without an approval card. Commands can also send data to public sites, including data they can read in the workspace. Under Add-ons → Host access → Sandbox, the network-check permission is granted; blanket host access stays off. Upgrades preserve the existing policy, including an implicit Off.
To restrict all chats, open Add-ons → Sandbox → Settings and set the limit to Custom or Off. If host policy withholds the network control, this section explains the restriction without offering an editor. A chat cannot approve a connection that the host forbids. To restrict just one chat, use Tools → Network in that chat; its choice persists without changing any other chat or the new-chat default.
Presets. A chat has one of three presets, and an administrator sets the ceiling, the widest preset any chat may use:
Preset
What a command reaches
Off
Nothing.
Custom
The HTTPS hosts of the package registries below, on port 443, plus the domains an administrator listed (extra registries, always allowed hosts and exact destinations, see below). The preset is stored as registries in chats, agents and the API.
Allow all
Every public host on a globally allowed port, plus individually granted destinations.
The preset of a chat is the lower of its own choice and the ceiling (chats_egress_ceiling). A new chat starts with chats_egress_default, capped by the ceiling. The preset lives in the chat’s record on the server, never in a file of the workspace: the sandbox can write the home, so a file there could be changed by the code it is meant to confine. A preset never reaches a private, loopback or link-local address, nor the server’s own addresses, nor a cloud metadata address. The server’s own addresses are the same list for web_fetch and the Sandbox: the interfaces of the server, loopback, and the addresses that the host of the external base URL resolves to (read again every 60 seconds); the add-on also refuses the interfaces of its own machine. With chats_egress_allow_private on, a host that an administrator allowed by a rule or a card answer may reach private addresses; the metadata addresses stay refused. See Runtime settings for the chats_egress_* settings.
Allowed destinations. In Add-ons → Sandbox → Settings → Allowed destinations, an administrator can grant an exact DNS hostname and TCP port, for example git.example.com:22 and git.example.com:8080. Enter each pair separately. Ports 1–65535 are valid, including 22 and 25. Bare names, URLs, ranges and wildcards are not entries. An empty list leaves the existing policy unchanged. A grant applies to the isolated Sandbox only: it does not add a port to the global list, cover another hostname on the same IP, or grant any other add-on access.
The host checks each new proxy request. Remove git.example.com:8080 and the SSH grant on git.example.com:22 still works. Removing an entry withdraws that exception; access independently permitted by ordinary policy is unchanged. To block just one pair in your chat, deny that host and port in Tools → Network. A chat denial, chat Off, or ceiling Off takes precedence over a grant. Address checks, connection limits and auditing still apply.
Using the proxy. If the service speaks HTTP, curl http://git.example.com:8080/status uses the guest HTTP proxy. For other TCP protocols the client must support HTTP CONNECT through 127.0.0.1:3128 or use a compatible transport helper. A grant does not give the guest a network interface. Port 80 requires ordinary proxied HTTP, not CONNECT; a tunnel to port 443 requires TLS with the matching server name. On other tunnel ports the server may speak first, but TLS clients must still send the matching server name. Grant only endpoints you trust: a grant permits connections to a service, not just one URL, repository or read operation.
Git over SSH. With github.com:22 granted, git clone git@github.com:OWNER/REPO.git uses the guest’s proxy-configured SSH client. Use a repository-scoped, read-only deploy key if the guest only needs to read.
The grant supplies neither a login nor a trusted host key. Provision the verified server public host key in the guest user’s ~/.ssh/known_hosts using a fingerprint from a trusted source. Provision a separate guest identity (for example ~/.ssh/id_ed25519, mode 0600) and authorize its public key on the Git server. Do not copy the LocalAI server’s keys, paste private keys into chat, or store them in shared workspace files. Guest commands can read credentials accessible to the guest user. The Sandbox does not forward the server’s agent or import its credentials. A proxy 403 means the tunnel was denied; Host key verification failed means the server is not trusted; Permission denied (publickey) means SSH reached the server but authentication failed.
Package registries. The list ships with LocalAI (core/services/studio/egress/registries.json) and changes only by a reviewed pull request that also changes this table and is named in the release notes. Every entry is an exact host name, HTTPS on port 443, with no pattern. Upload hosts (such as upload.pypi.org) are not on it, and neither is raw.githubusercontent.com, which serves any user’s content. An administrator adds exact hosts with chats_egress_extra_registries, for example an internal mirror (which is private and so also needs the private switch and an administrator’s rule). Extra registries are registries: they follow the registry rules (HTTPS only, and only with the Custom preset or a card). To allow one more host for any request, use the list below.
Always allowed hosts. An administrator can list exact hosts or whole-label patterns in chats_egress_allowed_hosts (at most 64; an optional :port pins the port). A host on the list is allowed, with no card, in every chat whose effective preset is Custom or Allow all, on any request kind (plain HTTP as well as HTTPS) and on the allowed ports (chats_egress_ports), or only on the pinned port. With the preset off in a chat nothing on the list is allowed there, and with the ceiling off the list does nothing at all. The list does not widen the guard: a private, loopback, link-local, metadata or server address is not allowed by it, only by the private switch together with an administrator’s rule or card answer, and the TLS server name must still match, on the pinned port as on 443. An administrator’s entry also wins over a deny the person stored in one chat before the host was listed. The audit line of a request this way has the reason allowed_host. The chat’s Network panel shows this list, with the extra registries, to the person under Custom domains, as written (patterns such as *.example.com and * included). An administrator gets an Edit domains link there that opens the Settings tab of the add-on at the network section; everyone else sees a note that an administrator manages the list. The list is not a second store: the panel reads chats_egress_extra_registries and chats_egress_allowed_hosts.
Patterns are *.example.com (every descendant, including a.b.example.com, but notexample.com) or * (any public destination). List the apex separately when needed. Names normalize case, IDNA and a trailing dot. Patterns support an exact port, such as *.example.com:8443 or *:443; the configured allowed ports still apply. Partial-label globs, wildcard ports, URLs and paths are invalid. Extra registries remain exact hosts only.
Wildcard grants remain inside the administrator’s ceiling: a Custom ceiling (registries) requires a listed registry and TLS, Allow all permits public destinations, and Off blocks them all. For compatibility, existing exact entries retain their exception for non-registry public hosts under the Custom ceiling, including plain HTTP. Wildcards never grant private access, even with the private switch enabled. DNS resolution, rebinding protection, metadata/server exclusions and TLS server-name checks still apply; a name match alone never authorizes a dial.
What the proxy checks. The host of a request goes through the same guard as web_fetch (Addresses inside your network): a canonical name or literal, no address zone, no numeric tricks, no localhost. A host the guard refuses is never resolved, so it does not leak through DNS. A name is resolved once; when any answer is not allowed the connection is refused, and the proxy dials the address it checked. The addresses of the node’s own interfaces, the whole loopback range and the server’s own addresses that LocalAI sends with each allow (see egress.check) are refused even when public. Only ports 80 and 443 by default (chats_egress_ports; 22 and 25 cannot be granted by this list; either needs its own exact destination grant). HTTPS goes as CONNECT host:443: after the tunnel opens, the first TLS record must be a ClientHello whose server name is the CONNECT host, or the tunnel is closed (this stops a tunnel to one tenant of a CDN that talks to another). A CONNECT to another allowed port (an always-allowed host:8443, or a port added to chats_egress_ports) may carry any protocol, and the server may speak first, so the proxy waits for nothing; but when the first bytes the command sends are a TLS record, they must be a ClientHello whose server name is the CONNECT host too, or the tunnel is closed with the audit reason sni. Plain HTTP goes as an absolute http:// URL: each request of a kept-alive connection is decided on its own, the Proxy-* and hop-by-hop headers are dropped, a Host header that names another host is refused, and every request gets a new upstream connection. CONNECT to port 80, the origin form, https:// in absolute form and Upgrade are refused with 400. The proxy follows no redirect: the guest’s client follows it with a new request, which is checked again.
Cards. When a command asks for a host that the chat’s preset does not admit but the ceiling would, and a person watches the chat, LocalAI stores a card in the chat and the person sees it in the chat: A command in this chat wants to reachhost:port (an international host name is checked and shown in its ASCII form, so a look-alike name such as pаypal.com with a Cyrillic а reads xn--pypal-4ve.com; a name with no valid ASCII form is refused), with Allow once (the rest of that command), Allow for this chat (a rule) and Deny (a deny rule, so the host does not ask again; it can be removed in the network panel). The connection waits for the answer for up to 60 seconds, and never past the call’s own timeout, so pip goes on by itself after the click; without an answer it gets the 403 line with the user did not answer. A late answer still counts: Allow for this chat stores the rule, and Allow once lets the next call of the chat reach the host within ten minutes. A card nobody answered expires when the chat’s turn ends; it stays visible as Not answered and can still be answered, with the same buttons, under the call that asked and in the network panel of the Tools menu. Ceiling off never shows a card; ceiling registries shows one only for a registry host (so a chat on Off can approve pypi.org); ceiling all for any public host. A host inside your network shows a card only with chats_egress_allow_private on, and only an administrator can allow it. A chat shows at most three cards at a time and one per host and port; a second connection to the same host waits on the same card. A card names the turn that asked it, and waits only while that turn holds the chat and its 60 seconds have not run out. When the frontend that ran a turn dies, its cards do not stay pending: they read as Not answered at once, do not count toward the three, and expire in the chat record when the reaper ends that turn, when the next turn starts, or when the next card is asked, whichever comes first. They can still be answered late, like any expired card. Unattended runs (triggers, connectors) and sub-agents get no card: the block is in their output. The card is written to the chat record before the answer is sent on the chat bus, and the waiting check reads it again every two seconds, so an answer given through any frontend reaches it within two seconds even when the bus message is lost. When the ceiling goes down while a card waits, the card is refused, and every answer to it gets 400 egress_above_ceiling (the same answer twice to an answered card is 204; another answer is 409 already_answered). A card the ceiling cannot admit shows no buttons: it says that network access is off (or limited) on this server, names who can change it, and gives an administrator a link to the Settings tab of the add-on that runs the commands (the network-policyhost control). The Network row of the chat’s Tools menu says the same (Off: the administrator has not allowed network access.) when the ceiling is off or below all.
What the model reads. When the Sandbox serves bash, each turn tells the model the preset in one line, such as Network for commands: package registries only (Python (PyPI), …). A blocked host asks the user; do not try to get around the proxy. When no card can appear (a ceiling no wider than the preset, an unattended run, a sub-agent), the line says instead that a blocked host is refused and nothing asks the user, so the model names the host it needs in its answer. A blocked request gets 403 with one line of text in the tool output, for example Blocked by LocalAI: example.com:443 is not allowed for this chat (off). Ask the user to allow it. With ceiling off, or a chat preset above the ceiling, the note of the turn says that the server’s setting keeps the network narrower, that no approval changes it, and that the model should tell the user instead of waiting or retrying. A request blocked for that reason gets the line blocked by the server’s setting for the Sandbox network, not by a missing approval; a block that waits on a person keeps the the user did not answer line.
Only while a command runs. The proxy knows the call in progress of each sandbox. A connection while no call runs (a background process left by an earlier command) is blocked with the reason idle, nothing is asked, and it is audited at the next call. When a call ends, every tunnel it opened is closed. The proxy caches no verdicts. Every new upstream connection requires a fresh egress.check from the owner, including each HTTP request on a kept-alive guest connection and every CONNECT tunnel. A tightened policy or an unavailable owner blocks the next connection immediately, even for the same host, port and command. Already-established streams may finish under their original authorization; a policy change does not interrupt them. Idle, byte and call-end limits still apply, but no verdict TTL bounds stream lifetime.
Limits. These are fixed in this release:
Limit
Value
Concurrent connections of one sandbox
32 (the guest agent caps all its ports at 64)
New connections of one sandbox
20 per second, burst 40
Concurrent connections of the add-on process
256
Dial timeout
10 s
Idle tunnel (no bytes either way)
120 s
Bytes from the guest, per call
64 MiB
Bytes to the guest, per call
4 GiB
Audit. Every verdict is a line of the audit (who, which chat, host, port, kind, verdict, reason), and every allowed connection adds a done line with the address it reached, the bytes each way and how long it lasted. The reason names the rule that decided: preset, allowed_destination (an exact host and port), allowed_host (the administrator’s always-allowed list), rule, once, denied, ceiling, port, private and the others the proxy adds, such as idle and sni. Lines older than chats_egress_audit_days (default 30) are removed daily, with the lines of the audit of the commands run on this machine.
What fails. Tools that connect directly, destinations not authorized by policy, direct TCP and UDP, ICMP and DNS from the guest fail, as before.
Residual risks. The presets bound what a command reaches; they do not make every reachable host safe:
A registry that takes uploads (npm publish with a token the command holds) can carry data out under “Custom”, and so can any host under “Allow all”. The preset is the person’s choice of risk; the per-call upload cap bounds the volume, not the risk.
Inside a TLS tunnel the Host header is encrypted and cannot be checked; a CDN that routes by it can still be reached through an allowed name.
A command that sees the proxy can try many hosts; each one is checked and audited.
Distributed mode. Each piece of state has one mode:
State
Mode
Ceiling, private switch, ports, extra registries, allowed hosts, default
owner-authoritative durable host policy when add-ons are enabled; Studio reads it per request. With add-ons disabled, existing local runtime settings apply
A chat’s preset, rules and cards
shared and durable: the chat record in the chat store (the database in a cluster)
A card that waits
stateless per request: the host operation on the owner waits; it wakes on the answer’s bus message or on a re-read of the card every two seconds
The decision of one connection
stateless per request: the host operation reads the settings and the chat record at each check
The map from a call’s resource to its chat
per instance: a cache of a fixed mapping (a hash of the chat ID); each frontend fills its own, and a miss only costs a search of the user’s chats
Audit
shared: the studio_egress_events table in a cluster, a JSON file under the data path, or memory without one
Audit pruning
single-runner: one frontend at each daily tick, under an advisory lock
Rate limits, connection counts
per instance: the add-on process on the owner; verdicts are not cached, so each new upstream connection checks the current owner policy
With --addons-role frontend a frontend runs no proxy; the owner does, and the host operations run on the owner’s host.
Packaging and setting up the Sandbox add-on
The Sandbox package is for Linux on amd64 and arm64, and for macOS on Apple silicon (darwin/arm64). For darwin/arm64, scripts/addons/package.sh signs its executable ad hoc with the virtualization entitlement (addons/sandbox/package/entitlements.plist) with codesign on a Mac or with rcodesign anywhere else, and fails when neither exists; fetch-runtime.sh fetches nothing for it, because its guests run in the Virtualization.framework of the system. A Mac that installs the package needs no other program. darwin/amd64 has no guest backend, so its row stays disabled. windows/amd64 runs the Linux add-on in WSL 2: its row has execution: wsl2, so the package carries the linux/amd64 executable and runtime files, its manifest has "osSettings": {"windows": {"execution": "wsl2"}}, and package.sh builds it on a linux/amd64 host. None of the backends runs on Windows itself (gVisor, KVM and the Virtualization.framework do not exist there, and the host backend needs a POSIX shell and process groups). The row stays disabled until its native check, which starts the executable through wsl.exe, passes on a Windows runner with WSL. In WSL 2 the host backend is off, also after its confirmation: there its commands could read the Windows drives under /mnt and start Windows programs. The requirements, the setup and the remaining risks are in Install on Windows. LocalAI never runs the commands of a chat on Windows without isolation.
runsc.addons/sandbox/package/runsc.json pins one gVisor release (20261012.0) with the URL, the checksum the release publishes for each tarball, and the checksum of the runsc inside it. addons/sandbox/package/fetch-runtime.sh <os/arch> <dir> downloads it, checks both checksums, and the release workflow puts runsc and gvisor-bin/ in the package. At run time the add-on checks runsc against the pinned checksum, copies it with its helpers to runsc/ in its data directory as executable files, and uses that copy. A runsc that does not match is never used. Without one in the package, a runsc in a system folder (/usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin) is used as it is. The add-on does not read PATH: LocalAI starts it with none, so it looks for runsc, taskset and the KVM tools in those folders only.
AppArmor. On Ubuntu 24.04 and later, a program needs an AppArmor profile to make user namespaces. The package carries gvisor-profile, a small program that prints the profile of one runsc. The add-on copies it next to runsc, and when gVisor fails for this reason the page tells an administrator the exact step, with the real paths. Run it once, as root, on the machine that runs LocalAI (not inside a container):
The profile names the binary by path, so a new runsc at a new path needs a new profile. Inside a container, AppArmor is that of the host: use a profile that allows user namespaces for the container (or --security-opt apparmor=unconfined), together with a seccomp profile that allows unshare and clone with CLONE_NEWUSER.
The guest images. The guest runs a Debian userland, the guest kernel and the guest agent. There is one image for each sandbox profile, and the Dockerfile has one target for each: base (the default target) media (base plus ffmpeg, sox, ImageMagick and rsvg-convert) and office (base plus LibreOffice Impress, Writer and Calc and fonts). The sandbox guest image workflow (.github/workflows/sandbox-images.yml) builds addons/sandbox/images/guest/Dockerfile for amd64 and arm64, pushes the images to one repository of the project registry (quay.io/go-skynet/sandbox-guest, which must allow anonymous pulls) with the tags sha-<commit> (base) media-sha-<commit> (media) and office-sha-<commit> (office), and, for a release, also v<version>, media-v<version> and office-v<version>. A tag is never moved: the workflow reuses an image whose tag exists, a release reuses the images of its commit, and the release event builds no image, so the digests stamped into a released add-on keep a tag and stay pullable. It checks that each pushed index has a linux/amd64 and a linux/arm64 image, and outputs each reference by digest. Each digest names an index of both architectures, so a Mac with Apple silicon pulls the linux/arm64 image, and its kernel, by the same reference as an arm64 Linux host. The package build passes them in SANDBOX_GUEST_IMAGE=<repository>@sha256:<digest> (base) and, optionally, SANDBOX_GUEST_IMAGE_MEDIA and SANDBOX_GUEST_IMAGE_OFFICE. scripts/addons/package.sh builds the add-on with -ldflags "-X main.guestImage=... -X main.profileImages=media=...,office=...". package.sh refuses a Sandbox build without the base variable; --local-check builds with a stand-in reference no registry serves, for a check that does not publish. To build an image by hand: docker buildx build -f addons/sandbox/images/guest/Dockerfile --target <base|media|office> . from the repository root.
The build check of a profile. The tools of each profile, with the command that proves each one works, are in the add-on manifest (execution.profiles). The Dockerfile copies the manifest into the image and runs check-tools.sh <profile> in each target, so an image does not build when a listed tool is missing. sh addons/sandbox/images/guest/check-tools_test.sh tests the script.
KVM.addons/sandbox/package/kvm.json pins Cloud Hypervisor v54.0 (amd64 and arm64) and virtiofsd v1.14.0 (amd64) with checksums, and fetch-runtime.sh puts them in the package. The add-on checks each against the checksum compiled into it and copies it, as an executable file, to kvm-bin/ in its data directory. Upstream publishes no static virtiofsd for arm64, so on arm64 install virtiofsd 1.13 or later in a system folder. The KVM backend also needs mke2fs and debugfs from e2fsprogs (the LocalAI image installs them) and access to /dev/kvm for the user LocalAI runs as. Bubblewrap is optional in a container: the add-on does not use it when it finds /.dockerenv or /run/.containerenv, or when SANDBOX_NO_BWRAP=1 is set in its environment (SANDBOX_NO_BWRAP=0 forces it). addons/sandbox/images/host/Dockerfile still builds an image with the same programs for a product that wants them in one place.
Tests in CI. The sandbox tests workflow (.github/workflows/sandbox-tests.yml) runs the Go tests and the end-to-end suite, the gVisor integration suite on amd64 and arm64 (with the pinned runsc and its profile loaded), the KVM integration suite on a runner that has /dev/kvm (it skips, and says so, on one without), and the release smoke test.
Release smoke test.scripts/addons/sandbox_smoke.sh takes the package that package.sh made, starts the add-on from the extracted files under the real supervisor with the default settings, and runs a command through the tool path of a chat. It passes when the command ran in gVisor or KVM, or, on a host that cannot, when every tool answers “This host cannot run commands.” and nothing ran. --require isolated makes the second case a failure.
The Sandbox in the LocalAI container
gVisor, KVM and the host backend refuse to run as root, so the sandbox needs the add-on process to run as an unprivileged user. The LocalAI container image starts as root only long enough to run entrypoint.sh. The entrypoint selects the user, makes the data folders writable for that user, and runs LocalAI as that user, with the groups that own /dev/kvm, /dev/kfd and /dev/dri/* added. The add-on runs as the same user. Container user and permissions explains how the entrypoint selects the user, and what to do with existing volumes, bind mounts, LOCALAI_UID, --user, rootless Podman and read-only containers.
Keep root. Set LOCALAI_RUN_AS_ROOT=true to run as root as before. The sandbox is then unavailable, and the page says why.
Devices. The KVM backend needs /dev/kvm; gVisor does not. For KVM, pass the device to the container (--device /dev/kvm); the entrypoint adds the group that owns it. In Kubernetes, request the device through your device plugin and give the pod a fsGroup or supplementalGroups entry for it.
User namespaces. gVisor needs the container to be allowed to create user namespaces, and on an Ubuntu 24.04 or later host an AppArmor profile that allows them (see AppArmor in Packaging and setting up the Sandbox add-on). Without them runsc stops at once, and the backend’s reason ends with exit status 128 and cannot read client sync file ... EOF. Docker’s default seccomp profile blocks this: use a profile that allows it, or --security-opt seccomp=unconfined on a host you trust. KVM needs /dev/kvm and no extra privileges.
Cluster. The add-on runs on the add-on owner node only. In Kubernetes, give that pod the settings above; a node pool dedicated to it is the way to keep the isolation requirements off the other nodes.
What the source tree does not prove: the images and the runsc download are not built in the test suite, and the gVisor and KVM backends need a host that allows them. Their tests skip with the reason on a host that does not. The host backend and the whole path from a chat to a file in the user’s files run in the tests.
Provider choices and automatic upgrades
Add-on skill switches and tool-provider choices read the owner policy and update only the changed provider keys. Clearing a choice removes that pin without changing other add-ons. Revision conflicts retain edits for an explicit reload and rebase. Uncertain writes retry the same operation; an owner outage disables writes until reconciliation. Native add-on configuration remains separate.
With add-ons enabled, Settings → Backends uses the owner policy for automatic upgrades rather than the frontend runtime file. Combined mode uses the embedded owner through the same API.
Backups and the guest images
A backup of the add-on’s data, and so the backup before an upgrade, holds the guest images
in images/. A restore, or the rollback of a failed upgrade, brings back the images as
they were, without a pull. KVM and macOS keep each image as a disk file. gVisor keeps the
image as one compressed file (rootfs.tar.gz) and unpacks it into unpacked/.
The add-on declares three folders of its data directory as cache folders (data.cache in
its manifest), which a backup does not copy: unpacked/ (the gVisor trees, which a backup
cannot copy with their links and file modes), runsc/ and kvm-bin/ (the copies of the
programs from its package). After a restore they are empty. The add-on copies the programs
again from the package that runs, and the first command of a profile unpacks its saved
image again.
A restore changes the data, not the installed package. Each package names the images it
uses by digest, so a restored image is used when the package that wrote the backup runs,
as after the rollback of a failed upgrade. A later package uses its own images.
An image that gVisor unpacked with an earlier build of the add-on has no
rootfs.tar.gz. The add-on pulls it once more, and a backup made before that does not
hold a usable copy of it. The backend settings and the image record
(profiles-cache.json) are in the backup too.
Because the images are in the backup, a backup is as large as they are, and the add-on is
stopped while they are copied and checked. Each kept backup holds its own copy.
Upgrade execution and polling
Browser upgrades are accepted durably by the add-on owner before the submission
returns. The response identifies the same operation used by subsequent status
reads. Closing a page, refreshing, or losing the acceptance reply does not cancel
accepted work. Accepted upgrades cannot be cancelled from the UI.
The Activity entry has no Cancel control after submission. A retry with the same operation ID, actor and payload observes that
operation; a changed payload conflicts. Only one asynchronous upgrade is admitted
at a time; competing submissions receive a conflict instead of entering a queue.
Other lifecycle service callers retain their synchronous contract.
Execution is single-owner, using the existing storage ownership fence and local
journal, not frontend memory or a message-bus dependency. Standalone uses the same
path. Any frontend can forward polling to the owner. Each read revalidates current
administrator authorization and the recorded actor, including credential identity.
Expired or revoked credentials cannot read the operation, but do not revoke work
already accepted. A different credential does not inherit the original receipt.
Activity shows real stages (package preparation, verified backup, candidate
migration/health, and publication), not estimated byte percentages. Failed
operations retain a safe failure code; detailed underlying causes go to owner
logs. A migration failure can require explicit data recovery; keeping the old
package does not mean the data is safe to run.
Shutdown cancels and waits for the owner worker before releasing storage. On
restart, existing publication and data-recovery journals reconcile before runtime
startup: prepared publication may finish; interrupted work otherwise becomes a
terminal interrupted failure, with recovery-required reported when data is blocked.
Destructive migration is never automatically replayed. An uncertain publication
remains fenced for reconciliation, not presented as a definite rollback.
The browser remembers pending operation IDs in session storage, scoped to the
signed-in user, and resumes observation after a reload without resubmitting.
Logout clears the current user’s observer records. Storage restrictions may prevent
observer recovery, but never cancel the owner operation. An unreadable owner or
exhausted polling window is an unknown outcome: keep the ID and read it again,
rather than starting a replacement operation.
LocalAI docs > Add-ons > Catalogue > Work tools
Tables
Keep structured data in a database of tables that you own, and ask a chat to read and change it. You can share a database with other people on your server and export a table as a CSV file. A new database is private to you until you share it.
For example, make a database called “Reading list” on the Databases page and add a table with the columns “Title” and “Status”. Open a chat, switch on Tables in the add-ons control, pick the database with Select database and ask: “Add The Dispossessed with the status reading.” The chat adds the row. Ask “How many books are done?” and it counts them. A change that a chat made can be undone.
At a glance
Topic
Detail
What it adds
Databases of tables that you own or share: typed rows, filters, a schema and sharing. A chat reads and changes them with tools.
Who installs it
An administrator, from Add-ons, Find add-ons, with Install, then turns it on. With authentication off, you are the administrator.
Who turns it on
A person needs the addons feature. It is off by default for new users on a server with accounts. The person switches the add-on on for a chat in the Tools menu. A saved agent uses it only when you name it in the agent.
Managing databases from the UI
Creating, renaming, sharing and deleting a database are the person’s own
actions in the Tables pages, through the routes described in
UI-only resource management. They
are not tools: a model never sees them and sharing and deletion are never
proposals.
databases-create and databases-rename are the same tools that chat uses,
run by the person’s explicit request with no approval card.
databases-delete is an admin tool. The manifest lists it in
capabilities.adminTools and not in tools, so it has no model definition and
the declared-tool rule refuses it on every other path. The addon runs it only
under the host action delete and only for the revision the owner confirmed.
It removes the file and its journal files and records the operation in the
ledger; repeating the operation, also after a crash between the removal and the
receipt, gives the same receipt.
The manifest capabilities.resources maps create, rename, inspect and
delete to these tools, with the noun database.
A database is shared whole, as viewer or editor, with named users picked by
account. An owner and an editor see the same rows; only the owner changes the
schema, shares, renames and deletes. Deleting asks the owner to type the name,
removes the data and every grant, and never uninstalls the addon.
The database of a chat
The owner keeps which database each conversation works on, per person. A tool
call that names no resourceId uses it, so a person can say “add a row” after
choosing a database once. The model never sets it, and the owner authorizes it
for the person on every call: a database whose grant was withdrawn or that was
deleted is refused like an unknown one. With none selected the tool answers a
select_resource result and runs nothing.
The Tables pages
Tables ships its own UI as a standalone ES module in the package. It is loaded by
the host after the host was built, so installing or updating Tables changes the
pages without a rebuild of LocalAI. The My add-ons page shows a Tables card.
Where
What
Databases list
Your databases and the ones shared with you, each with your role, who shared it and, for the owner, how many people have access. Create, rename and delete (owner).
A database
The tables as tabs, the typed grid of the selected table, a structured filter, sort by column, cursor paging and the row actions of your role.
Schema (owner)
Create, rename and drop tables and columns. A drop says what is lost and asks for the name to be typed.
Share (owner)
The whole database is shared as viewer or editor with named accounts found by a picker. Local-owner mode says that sharing is not available and makes no sharing call.
Select database
A chat action in the composer menu: the databases you may use with your role, the one selected for this conversation, and a way to clear it.
What each role sees:
Role
Rows
Schema
Share, rename, delete
Owner
read, add, edit, delete
yes
yes
Editor
read, add, edit, delete
read only
no
Viewer
read
read only
no
Hiding a control is never the control. The server checks the role of every call
again, and a crafted write of a viewer, a schema change of an editor or a share
of anybody who is not the owner is refused with the answer of an unknown
database.
Editing rows
Typed editors. Text, whole number, number, yes or no, and date and time
(entered and shown in UTC). A value of the wrong type is refused in the form
and nothing is sent. Integers beyond 2^53 are kept exact. An optional column
has an Empty switch that sends null.
Filters. A list of conditions over the table’s own columns, joined by
all or any, with the operators the column type supports. They become the
filter of rows-query; there is no free text and no expression. The row
ID is filterable as _id.
Paging. The add-on’s cursor goes forward and the page keeps the cursors it
used to go back. A cursor that the add-on no longer accepts (the data
changed) starts again at the first page and says so.
Batches.Add rows takes up to 100 rows. A selection is changed or
deleted in steps of at most 1000 row IDs, each step saved on its own with its
own operation ID. If a later step fails, the page says how many rows were
changed before it.
Revisions. Every change sends the revision the page read. If another
person changed the database, the save is refused as stale, the form keeps what
you typed and offers Reload and apply again, which reads the revision and
sends the same change once more under a new operation. An unknown outcome
keeps the operation ID, so repeating is the same change and never applies
twice.
A row editor sends only the fields you changed. A datetime keeps its stored
fraction of a second (up to nine digits) when you edit another field, and two
spellings of one instant, such as another UTC offset, are no change.
Row and schema changes made in these pages are the person’s own action. They
need no confirmation card and are not proposals, and they still go through the
host’s POST /api/addons/resources/{resourceId}/apply: the role of the action,
the declared tool definition, the admission of the resource, the revision and
the receipt (see Changing data and schema from the UI).
The database of a chat
Choosing a database in the Select database action stores it for you, the
conversation and the add-on. A chat tool call that names no database uses it,
and the chat sends the conversation ID in the X-LocalAI-Conversation-Id header
only when the conversation has add-on tools enabled. Two people in the same
conversation ID, or one person in two conversations, never share a selection. A
database that is no longer shared with you is refused like an unknown one.
CSV export
rows-export writes the rows a table, a filter and a sort select to a CSV
file. It is a read: it runs under the host read action, so an Owner, an
Editor and a Viewer may export what they can read, and it needs no approval
card. A chat tool call and the Export CSV button of a table page run the
same tool.
columns, filter and sort follow the rules of Row queries.
columns may name _id to write the row ID as a column; empty exports every
column in schema order. maxRows is optional. There is no limit and no
cursor: an export is the whole result, not a page.
What the file holds
One snapshot. The export reads the database in one read transaction, so every
row comes from the same revision. A change that commits while the export
runs is not in the file, and the export never blocks it. The file is written
row by row through a small buffer; its memory use does not grow with the
number of rows.
RFC 4180 records with a header row of the column labels and CRLF line ends.
A field is quoted when it holds a comma, a quote, a CR or LF, or starts or
ends with a space or tab. A quote inside a field is doubled.
UTF-8, with no byte order mark. Text is written as it is stored. A
spreadsheet that guesses the encoding from the file may need to be told to
read it as UTF-8.
NULL is an empty field with no quotes. An empty text value is "". A reader
that does not tell the two apart reads both as an empty value.
Booleans are true or false. Integers are decimal and exact to 64 bits.
Reals are the shortest decimal that reads back as the same number; very large
or very small values use an exponent. Date-times are RFC 3339 in UTC.
Spreadsheet formulas
A spreadsheet runs a cell that starts with =, +, -, @, a tab or a
carriage return as a formula. The export therefore writes a single quote
before every text cell, and every column label, that starts with one of
those characters, as the OWASP guidance recommends: =1+1 is written as
'=1+1. A spreadsheet shows the quote as the text marker, not as part of the
value.
Limits of this policy:
Cells of integer, real, boolean and date-time columns are never prefixed. A
negative number stays a number (-4).
The file now holds '=1+1, not the stored =1+1. A program that reads the
CSV back must remove that quote itself; the export does not mark which cells
it changed. A text value that really starts with ' and a formula are
therefore not told apart after the round trip.
A text value such as -5 apples also gets the prefix.
The policy protects the file against being run as a formula in a spreadsheet.
It is not a defence for a program that treats CSV as trusted input.
In the pages and in chat
A table page has an Export CSV button for every role. It exports the table
with the filter and sort of the view, optionally with the row ID, and then
shows the host’s file card: name, size, expiry and the download button. In
chat, an export tool call is answered with the same card. The chat stores only
the artifact identifier; after expiry the card says the file expired.
Events for automations
Each row change that commits is reported: tables.row.created (a row is
added), tables.row.updated (changed) and tables.row.deleted. An undo of a
row change is reported as what it does: an undone insert removes rows. Each one
carries the database and the table (ID and name), and the row: its number, a
key, a title (its first text value) and, except for a removal, its values by
column name. A start chooses one of the person’s databases and, if it wants,
one table; it then gets only the rows of that choice. The columns of the chosen
table are fields an automation can filter on. One change reports at most its
first 50 rows. The add-on asks for the host operation events.emit at
install; without it, nothing is reported.
Limits
One name per database, no uniqueness rule across databases.
Rename needs the schema revision from the preview. A changed schema makes
the rename rejected, and a new preview is required.
The data directory holds the databases and a small operation ledger. Both
are kept when the addon is disabled or uninstalled.
LocalAI docs > Add-ons > Catalogue > Work tools
Calendar
At a glance
Topic
Detail
What it adds
One calendar for each user, inside LocalAI. A chat or a saved agent reads and changes events. There is no account to connect.
Needs
Nothing. There’s no account to connect.
Ask a chat or a saved agent “what is on Thursday?” or “add dinner with Sam at 8” and it reads or changes your calendar. Install it and ask. There’s nothing to connect. Writes run at once, with no confirmation card.
What it keeps
There is one calendar for each user, shared by all of that user’s chats and agents. It is one SQLite file in the data directory of the add-on. An event has:
a title, a start and an end, or a whole day (an all-day event);
notes, a place and the attendees, each as free text;
a time zone, as an IANA name such as Europe/Rome, and optionally a repeat.
Set the default time zone once, on the Calendar page (it starts as the zone of the server). A new event uses it unless you or the agent name another one. An event keeps the zone it was written in when you change the default.
A repeat is daily, weekly, monthly or yearly, with an interval (“every 2 weeks”) and an optional last day. The local time stays the same across a change of daylight saving time. A monthly repeat on the 31st skips months that have no 31st. You can change or delete the whole series, or skip one occurrence.
It doesn’t sync with other calendars, send invitations, hold more than one calendar per user, or send reminders. To move events elsewhere, export the whole calendar as one ICS file from the page.
The page
Open Calendar in the add-ons. It has a month view, an agenda list of the next 60 days, a form to create or change an event, the default zone and the export button. Click a day to add an event, or an event to change, skip or delete it. The page speaks the language of the web UI.
What the agents can do
Tool
Does
events-list
Lists a range of days with repeats expanded; with no arguments, today and six more days.
events-search
Finds events by words in the title, notes, place or attendees.
event-get
Reads one event in full.
event-create, event-update, event-delete
Add, change and delete an event. With occurrence (a date), event-delete skips only that day of a repeating event.
Reads and writes both run immediately, as the signed-in user, with no confirmation card. A trigger or a job can write only with the act.addons grant. The add-on ships a skill that tells the model when to use the tools.
In a messaging chat, the owner and the senders paired with the bot can read and change the calendar. Every other sender the bot lets in can read it but not change it (the tools.write rule, see Add-ons that keep the owner’s own data).
Events for automations and watches
The calendar reports each change: calendar.event.created (an event is added), calendar.event.updated (changed, or a day of a repeating event skipped) and calendar.event.deleted. An automation can start from them, and a watch can remind you of an event. Each one carries these fields, under event: the ID, the title, the next start (a time; absent when no occurrence is left), the start and end in the zone of the event, whether it lasts all day, the zone, the place, the attendees and the notes. A removal carries only the ID and the title.
When a watch handles an added or changed event, the calendar asks the model to consider a prep task with a lead time for a call or meeting with other people.
Limits
An event title has at most 200 characters, notes 4000, a place 200 and attendees 500. One user keeps at most 5000 events. A listing covers at most 400 days and returns at most 500 occurrences; the page says when a list was cut.
LocalAI docs > Add-ons > Catalogue > Work tools
Contacts
At a glance
Topic
Detail
What it adds
One address book for each user, inside LocalAI. A chat or a saved agent looks up and keeps contacts. There is no account to connect.
Needs
Nothing. There’s no account to connect.
Ask a chat or a saved agent “what is Marco’s number?” or “add Anna, anna@example.org” and it reads or changes your address book. Install it and ask. There’s nothing to connect. Writes run at once, with no confirmation card.
What it keeps
There is one address book for each user, shared by all of that user’s chats and agents. It is one SQLite file in the data directory of the add-on. A contact has:
a name, and an organisation;
phone numbers and email addresses, each with a free label such as mobile, home or work (up to 10 of each);
a birthday, as YYYY-MM-DD, or --MM-DD when the year is not known;
an address and notes, each as free text.
It doesn’t sync with another service, support CardDAV, groups or photos, or merge duplicates. It can’t import vCard files yet. You can export the whole book as one vCard file from the page.
The page
Open Contacts in the add-ons. It has a search box, the list of contacts, the detail of the one you pick, a form to add or change a contact, and the export button. The search matches every word you type against the name, organisation, phone numbers, email addresses, address and notes. It ignores case and accents, and a phone number matches however it is spaced. The page speaks the language of the web UI.
What the agents can do
Tool
Does
contacts-search
Finds contacts by words, and gives a short card for each match with the phones and emails.
contact-get
Reads one contact in full.
contact-create, contact-update, contact-delete
Add, change and delete a contact. A phones or emails list in an update replaces the whole list.
Reads and writes both run immediately, as the signed-in user, with no confirmation card. A trigger or a job can write only with the act.addons grant. The add-on ships a skill that tells the model when to use the tools.
In a messaging chat, the owner and the senders paired with the bot can read and change the book. Every other sender the bot lets in can read it but not change it (the tools.write rule, see Add-ons that keep the owner’s own data). The book is private to its user: a tool call can never name another user’s book.
Events for automations
The book reports each change: contacts.contact.created (a contact is added), contacts.contact.updated (changed) and contacts.contact.deleted. An automation can start from them and filter on their fields. Each one carries, under contact: the ID, the name, the organisation, the emails and phones (each with a label and a value), the birthday, the address and the notes. A removal carries only the ID and the name. The add-on asks for the host operation events.emit at install; without it, nothing is reported.
Limits
A name has at most 200 characters, an organisation 200, a label 40, a phone number 40, an email address 254, an address 500 and notes 4000. One user keeps at most 2000 contacts.
A vCard export is a vCard 3.0 file. A birthday without a year is written as --MM-DD, which some programs do not read.
LocalAI docs > Add-ons > Catalogue > Work tools
Web search
Web replaces the built-in web_search and web_fetch tools. The built-ins need no key. Install this add-on to search with Brave, Tavily or Google Programmable Search, and to read PDFs in web_fetch.
The add-on has its own switch in the Tools menu of a chat. The switch on the Web row changes only the built-in tools.
At a glance
Topic
Detail
What it adds
Search providers that need a key (Brave Search, Tavily and Google Programmable Search), tried in the order an administrator sets, and the text of PDF files in web_fetch.
Needs
Nothing to start. For a search provider with a key, an administrator saves the key on the Settings tab of the add-on.