mirror of
https://github.com/mudler/LocalAI.git
synced 2026-11-05 20:13:23 -05:00
fix(chats): show the network switcher and say why execution status is unknown
The Network row of the Tools menu could never show the Off, Registries and All switcher: the host stopped setting `applies` because isolation alone does not prove network-policy enforcement, and nothing else set it. Let the provider report enforcement in its typed execution status (`networkPolicyEnforced`). The host sets `applies` only when that report is true and the status is available and isolated. The Sandbox reports it for the gVisor and KVM backends, whose guests reach the network only through the proxy that asks the host. Providers that do not report it keep the "not enforced" text. When the host cannot read the status, give the unknown state a reason (`unknown_reason`) in the API and the Tools menu: owner unreachable, not reported, stale, invalid, not selected, no answer or reported unknown. Log the class of each failure, rate limited. After a failure that a restart of the add-on owner can cause, let a long turn bind and read again, at most once every five seconds, instead of keeping the first failure for the whole turn. The Sandbox now reports "unavailable" with a reason when it started without settings, and explains a backend it does not know. When the Sandbox document skills are hidden because the Sandbox is not known to be isolated, say so in the skill list, in the turn note and in the `load_skill` error, instead of "This chat has no skills now". Assisted-by: Claude Code:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
26 files changed
+833
-81
No files matched your search
@@ -235,10 +235,18 @@ The existing result envelope carries this JSON in `payload`:
|
||||
{
|
||||
"readiness": "available",
|
||||
"isolation": "isolated",
|
||||
"explanation": "Commands use the configured isolated backend."
|
||||
"explanation": "Commands use the configured isolated backend.",
|
||||
"networkPolicyEnforced": true
|
||||
}
|
||||
```
|
||||
|
||||
`networkPolicyEnforced` is optional and false when absent. A provider sets it to
|
||||
true only when every network connection of its commands goes through the host's
|
||||
network policy (the Sandbox does, through its proxy). The host honors it only
|
||||
for a status that is `available` and `isolated`; it then shows the chat's
|
||||
Network row. Without the report the chat says that network-policy enforcement is
|
||||
not verified for the provider.
|
||||
|
||||
`contract.DecodeExecutionStatus` accepts at most 2048 UTF-8 bytes. Both enums
|
||||
are required: readiness is `available`, `unavailable` or `unknown`; isolation
|
||||
is `isolated`, `host` or `unknown`. Optional explanation is nonempty plain text,
|
||||
@@ -254,7 +262,7 @@ not an addon ID or a private settings payload. Prompt construction, command
|
||||
status and nested egress reads share one observation within a turn. Priming and
|
||||
standalone command-status or egress requests have separate, bounded scopes.
|
||||
Consumer cancellation stops that wait; turn completion cancels the observation.
|
||||
Failed reads settle as unknown and do not retry within the same scope. Each
|
||||
A failed read settles as unknown with a reason (`unknown_reason`: `owner_unreachable`, `not_reported`, `stale`, `invalid_status`, `not_selected`, `no_answer` or `reported_unknown`), which the Tools menu shows. It is not retried at once. After a failure that a restart of the add-on owner can cause (`owner_unreachable`, `no_answer`, `stale`), a scope that is still open (a long turn) binds and reads again, at most once every five seconds. A refusal of the binding or of the payload is not retried. Each
|
||||
consumption revalidates the complete owner binding, including conversation,
|
||||
current selection identity and runtime incarnation.
|
||||
|
||||
@@ -4895,6 +4903,11 @@ Request/session integration shares observations only within a bounded request.
|
||||
|
||||
### Execution safety notices
|
||||
|
||||
The Sandbox document skills (`docx`, `xlsx`, `pdf`, `pptx`) are offered only
|
||||
while the Sandbox reports an isolated backend. When it runs the chat's commands
|
||||
and is not known to be isolated, the skill list and `load_skill` say so, with the
|
||||
reason the status is unknown, instead of saying the chat has no skills.
|
||||
|
||||
The chat Tools menu and command chip describe the actual selected execution
|
||||
provider, not an installed app's name. Any provider that reports host execution
|
||||
gets a no-isolation warning. Unknown readiness or isolation gets an explicit
|
||||
|
||||
@@ -895,7 +895,7 @@ The routes, for the chat's owner (another user's chat is 404):
|
||||
|
||||
| Route | What it does |
|
||||
|---|---|
|
||||
| `GET /api/chats/{id}/egress` | `{preset, ceiling, effective, applies, applies_reason, addon, registries, allowed_hosts, rules, cards}`. `applies` is false when commands run on this machine (`applies_reason` `host`) or no Sandbox serves `bash` (`none`). `addon` is the add-on that runs the commands and draws the network controls of the chat (it has the `network-policy` [host control]({{%relref "features/addons#host-controls" %}})); it is absent when `applies` is false or that add-on has no such control, and the chat then shows no Network row. A rule the ceiling no longer admits has `above_limit`. |
|
||||
| `GET /api/chats/{id}/egress` | `{preset, ceiling, effective, applies, applies_reason, addon, registries, allowed_hosts, rules, cards}`. `applies` is true when the add-on that serves `bash` reports, in its typed execution status, that it enforces the network policy and the status is available and isolated (the Sandbox does, except on the host backend). It is false when commands run on this machine (`applies_reason` `host`), no Sandbox serves `bash`, or the add-on does not report enforcement (`none`). `addon` is the add-on that runs the commands and draws the network controls of the chat (it has the `network-policy` [host control]({{%relref "features/addons#host-controls" %}})); it is absent when no add-on runs the commands or that add-on has no such control. The chat shows the Network row only when `applies` is true and `addon` is set; otherwise it shows a line that says why the settings do not apply. A rule the ceiling no longer admits has `above_limit`. |
|
||||
| `PUT /api/chats/{id}/egress {preset}` | Sets the preset: `off`, `registries` or `all`. Above the ceiling it is 400 `egress_above_ceiling`. |
|
||||
| `DELETE /api/chats/{id}/egress/rules/{host}/{port}` | Removes an allow or deny rule. |
|
||||
| `POST /api/chats/{id}/egress/consent {id, decision}` | Answers a card: `once`, `chat` or `deny`. Allowing a host inside your network needs an administrator (403). The same answer sent twice is one answer (204, nothing changes). Another answer to a card already answered is 409 `already_answered`. A host the ceiling does not admit refuses the card and gives 400 `egress_above_ceiling` on this answer and on every later one, so a stale card never ends in a conflict loop. In `GET /api/chats/{id}/egress` such a card has `above_ceiling`: no answer can make it work. |
|
||||
|
||||
Reference in new issue
Block a user