We moved theloop, our open-source agent loop, into closed networks, and it exposed four assumptions in its deployment path: the model is a public API, tools live on public HTTPS hosts, the image comes from a registry, and the journal may hold prompts and answers. In a closed network the model runs on a GPU box at 10.20.30.40, sometimes over plain HTTP and without a key, and "we don't log customer data" has to be something a security team can test.
v1.5.0 is the release that addresses them. These are the traps we found, most of which apply to any agent runtime behind a firewall, in roughly the order an installer hits them, with the limits that remain.
1. Install: there is no registry
- Ship files, not just an image. Every release carries
docker savetarballs for amd64 and arm64, a Node bundle that runs withnode dist/index.js, a CycloneDX SBOM, third-party licenses andSHA256SUMS. The release job rejects native addons and dependency install scripts, so the same bundle runs on supported Linux systems; you supply Node.js 22.9 or newer. - Non-root, read-only root filesystem. OpenShift's default restricted policy, and Kubernetes clusters that enforce non-root, can reject root workloads. The image defaults to uid 1000, supports an arbitrary uid with gid 0, and writes nothing outside its journal volume, which must be writable by that identity.
- Secrets come as files. Every secret variable has a
_FILEtwin (ENGINE_TOKEN_FILE,*_API_KEY_FILE), and setting both is a startup error rather than a guess about which one wins.
One honest gap: the release workflow can sign the checksums with cosign, but the signing key isn't published yet, so v1.5.0 ships unsigned checksums. Until it is, bring SHA256SUMS into the closed network through a channel you trust.
2. Egress: opening the private network without opening SSRF
An agent engine makes outbound requests from URLs in the request: tool endpoints, the callback, image URLs. In the cloud, refusing every private address limits which internal services can be reached that way. In a closed network, everything is a private address: the model, the tools and the callback all live on 10.x.
The lazy fix is a flag that allows private ranges. What we did instead:
- Name the ranges.
EGRESS_PRIVATE_CIDRSopens only the listed CIDRs, and the host still has to be on the allowlist. Allowlist entries can carry a port (llm.corp.internal:8000); for anything private, give one. - Keep DNS pinning. The engine resolves the name itself, filters every answer, and connects only to an accepted address, so a name that later resolves somewhere else doesn't walk through the allowlist. Redirects are still refused.
- Some addresses are never allowed. Link-local (including the cloud metadata endpoint at
169.254.169.254), unspecified and multicast ranges are refused whatever the config says, and a configured range that overlaps them stops the engine at startup. - Normalize before you compare.
::ffff:169.254.169.254, its hex form::ffff:a9fe:a9fe, NAT64 and 6to4 addresses all embed an IPv4 address. Check the IPv6 string and they pass; normalize first and they're refused like the IPv4 they carry. - Plain HTTP per host.
EGRESS_HTTP_HOSTSpermitshttp://only for listed hosts that also pass the destination and address checks. Credentials and payloads then travel without encryption or integrity protection; theegress_plaintextwarning logged on first use is a reminder, not a safeguard. Prefer TLS. - Allow by purpose. Configuring a model server opens its origin for model calls only. It doesn't make that host a valid tool endpoint or callback target.
Two boundaries the engine can't hold for you. The harness supplies tool endpoints and the model supplies arguments, so a tool server that fetches a URL from those arguments needs its own SSRF controls. And EGRESS_PUBLIC_PROVIDERS=0 rejects any model entry whose destination is still a built-in public provider host, at validation, including entries in a fallback chain. It catches a misconfigured request early; it is not network isolation, which is still your platform's job.
3. TLS: the corporate CA, and cipher suites the runtime lacks
Internal services present certificates from an internal CA. Turning off certificate verification is not an option in theloop. Set NODE_EXTRA_CA_CERTS, before Node starts, to a PEM bundle that contains the corporate CA and any extra CAs from the image you still need, or build a derived image with the CA added through its certificate directory.
A trap specific to some regions: national TLS standards. Some internal services in Russia require GOST cipher suites, and the standard Node.js runtime theloop ships with doesn't provide them; v1.5.0 has no supported configuration for it. Put a GOST-capable proxy on that connection path.
4. The model: endpoints, gateways, and the key you didn't mean to send
A local model server, or an internal gateway in front of one, is an endpoint: LLM_ENDPOINT_<NAME>_URL plus optional settings for its dialect (OpenAI- or Anthropic-compatible), context window, capabilities and concurrency. A request names it as { "provider": "endpoint", "endpoint": "local", "model": "qwen3:8b" }. Not every closed network runs open-weight models, though: many run a corporate gateway in front of a cloud provider, or an on-prem installation of the same API. A base URL override per named provider (OPENAI_BASE_URL, ANTHROPIC_BASE_URL…) keeps that provider's behavior and its env key, and still goes through the egress rules.
Three traps here:
- The keyless endpoint that sends your key anyway. Internal model servers often have no authentication, and the obvious implementation, "no key, so don't set one", has a hole: some SDKs fall back to an environment variable when no key is passed. The Anthropic adapter reads
ANTHROPIC_API_KEY. On a box that also has a cloud key, a "keyless" request to an internal Anthropic-compatible server would carry that key to it. For Anthropic-kind endpoints the engine passes an explicit placeholder so the SDK never falls back, and its fetch wrapper removes credential headers when no key is configured. Tests run both dialects keyless with Anthropic and OpenAI keys configured and assert that the mock server sees no credential. Keyless still means unauthenticated: keep such servers away from untrusted clients. - GigaChat has two destinations, the API and OAuth. An on-prem installation needs both
GIGACHAT_BASE_URLandGIGACHAT_OAUTH_URL; setting only one is a startup error rather than a token request sent to the public internet. - A proxy plus an override is refused at startup. A provider proxy hides the DNS answers the private-network checks depend on.
5. The context window cut you won't see
This is the trap that costs the most, because often nothing fails. A local model server's context is whatever it was started with, and Ollama picks a default by version and available memory that's often far below the model's maximum. Send a longer prompt to Ollama and it can truncate it without returning an API error: the model loses earlier turns and tool results and answers anyway, without them. Its own logs may warn; your users won't see that. vLLM, by contrast, normally rejects a request over its configured limit. Pin the server version and check how yours behaves.
Either way, the engine should trim before the server does:
- Set the server's context explicitly:
OLLAMA_CONTEXT_LENGTHornum_ctxfor Ollama,--max-model-lenfor vLLM. - Tell the engine a smaller number, about 20% below the server's. The engine estimates tokens by characters, not with the model's tokenizer, so it needs headroom. Without a window set for an endpoint, it logs
endpoint_context_defaultat startup.
It still isn't airtight. The engine trims middle turns only: it keeps the first user message and the last four messages, so one huge pasted document can exceed the server's context on its own. npm run smoke:local checks a live server, including an oversized history the engine has to trim first.
6. Reasoning and tool calls: "OpenAI-compatible" varies
Reasoning models can put their thinking inline, as <think>…</think> inside the answer text. Whether the API returns it separately depends on the model, the API path, the template and the server version. The engine doesn't parse the tags out of the text, on purpose: text streams to the user as it arrives, so by the time a closing tag shows up the thinking has been displayed, and an answer can legitimately contain the string. Check that the exact endpoint theloop calls returns reasoning separately: for vLLM, configure the matching --reasoning-parser; for Ollama, use the reasoning controls its OpenAI-compatible API supports in your version. Otherwise your users read the model's inner monologue.
Replaying reasoning is a separate setting. For OpenAI-kind endpoints the default stores structured reasoning in the history without sending it back, because many local chat templates drop past thinking anyway; set _REASONING_REPLAY to reasoning or reasoning_content if your server expects it. Anthropic-kind endpoints replay reasoning under their signed or unsigned policy.
Tool calling varies too. Our tests construct Ollama-style and vLLM-style streams covering what we had to handle:
- a tool call that arrives whole in one chunk instead of as argument deltas;
- usage in the final chunk, or absent, in which case it's estimated and flagged;
- reasoning in a
reasoningfield on one server andreasoning_contenton another.
And a server may ignore tool_choice: none, which the engine uses for steps where tool calls are forbidden, such as the last step of a run. For such a server set LLM_ENDPOINT_<NAME>_TOOL_CHOICE_NONE=0, and the engine omits tools on those steps instead. Use models with native tool calling in your server; vLLM needs --enable-auto-tool-choice and a tool parser.
7. One GPU, many tenants
Ollama's parallel capacity depends on the model, available memory and OLLAMA_NUM_PARALLEL; excess requests queue inside Ollama or get an overload error, which from the outside looks like a flaky model. Set the endpoint's concurrency to the server's parallelism, and excess runs wait in the engine's queue instead, where they're visible.
By default, requests to the same configured endpoint share one queue across keys: tenants passing different keys to the same box still share its capacity. (Two endpoint names pointing at one server get two queues.) Waiting counts against the run timeout and the queue timeout, so real overload still ends in provider_queue_timeout, just a clear one. A gateway with per-key limits can switch to per-key queues.
8. "We don't log content" is harder than a flag
We already had a switch that kept prompts and answers out of the journal. An audit of where text actually goes showed why it wasn't a guarantee. Content leaks through provider and network error messages that quote the request, a callback receiver's error response, validation errors and exception messages that quote the input, exception stacks (which embed the message and can carry forged frame-like lines), URL paths, tool names the model invented, meta values, and call ids copied from the provider.
So it became a policy with a registry and a test. Every event field is registered as safe, an identifier, or a content class. With LOG_CONTENT=none, excluded content fields are dropped and excluded metadata becomes [omitted]; stacks and provider request ids are dropped, provider tool call ids become c1, c2, and string fields the registry doesn't know are dropped. A canary test plants one string in the system prompt, history, tool arguments and results, provider errors, URLs, exception messages, an undeclared tool name and more, and fails if it shows up in stdout, the memory journal, the disk journal or the error webhook. A harness can also narrow logging per request, for tenants under stricter rules.
The conditions matter as much as the mechanism:
- Identifiers are still logged. Session ids, idempotency keys,
metakeys and declared tool, skill, model and endpoint names appear in every mode, so the harness must keep customer content out of them. - The default is still
all, and switching modes doesn't scrub existing journal files. - It filters the engine's records, not the API. Run responses, the stream and callbacks still carry content, and run state stays in memory until its retention ends. Shorten retention if that matters.
The old switch is now an alias for this mode, so it removes strictly more than before.
Two more things a security review asks. Does it call home? theloop has no telemetry, update checks or license calls. A regression test instruments socket connections and DNS: startup, health, metrics, logs and a refused run produce no outbound activity, and a run against an endpoint serves as the positive control. Outbound traffic comes only from what you configure: model calls, tools, callbacks, the error webhook. How do we monitor it? GET /metrics serves Prometheus with its own token, so a scraper never holds the harness credential, and labels are bounded: no tenant, session or tool-name labels, and model names capped at a fixed number of values.
What's still missing
- No TLS listener. Terminate TLS at a reverse proxy or ingress in front of the engine. mTLS is a later candidate.
- One instance, as before. No high availability in v1.
- No encryption of the disk journal at rest. Use volume encryption.
- No inline
<think>parsing for servers that can't return structured reasoning. - No signed checksums yet, as above.
The compose file with Ollama and a Kubernetes example are in deploy/; the design, including what we deferred, is in RFC 0004.
If you've put an LLM stack into a closed network, which of these bit you, and what did I miss? Tell me.
Written with AI assistance and reviewed by the author. theloop behavior refers to v1.5.0; the behavior of Ollama, vLLM and other servers depends on their versions and configuration.