Engineering
How we made our agent start twice as fast
Each chat turn used to start our agent from a cold Python process. We now hand the turn to a process that has already loaded everything, and follow-ups reach the model in about 1.5 seconds instead of 3.5.
By Hung Hoang
When you chat with a Zalos AI worker, every message runs as an agent turn in an isolated cloud sandbox. Each turn starts our internal harness, which launches the agent, streams its work back to you and records the result. On a follow-up, the agent spent about 3.5 seconds before it sent the model anything, mostly starting Python and loading code it had already loaded on the previous turn.
We now hand each turn to a process that loaded everything in advance. Follow-ups reach the model in about 1.5 seconds.
Where the seconds went
Each turn runs as a fresh process by design. It gets its own short-lived credentials and its own process group, so stopping a turn means killing that group and nothing else.
We sampled the agent's main thread every 5 milliseconds from launch to its first model request. Python start-up took about 0.6 seconds, command-line and runtime imports about 0.85, and creating the model client about 0.6. Turning off unused plugins helped opening turns but not follow-ups, because that work ran on background threads. The remaining cost was the process itself.
Why not keep one agent running?
The usual fix is a long-lived server, as in OpenAI's Codex App Server. Our turns depend on having a process each: credentials are bound into clients at start, Stop and browser hand-off kill the turn's process group, a browser switch relaunches the turn, and each turn streams to its own files. Moving all of that into one shared process meant rewriting the parts of the system that make a turn safe to stop.
So we kept a process per turn and started it early. We tested the idea by hand in a live sandbox first. A normal launch reached its first model request in a median of 3.60 seconds over 8 runs; a process that had pre-imported the runtime took 1.76.
One constraint shaped the design. The harness for a follow-up starts the agent within about 0.14 seconds of starting itself, leaving nothing to overlap. The warm process has to be started after one turn ends and picked up by the next turn's harness, a process that did not start it.
Inside the pre-warmed process

Each pre-warmed process serves exactly one turn and never forks.
1. Spawn. After a successful turn, the harness starts the next process in its own process group. It imports the runtime and waits on a private socket, holding about 125 MB and no CPU. It exits if unclaimed for 20 minutes.
2. Claim. The next turn's harness claims it with an atomic file rename, then checks that it is alive and was started by the current harness and runtime.
3. Hand over. The harness sends the turn's arguments, environment and output paths. The process starts only after a ready/go exchange, so a turn can never run twice.
4. Run and report. The process runs the agent's normal entry point and writes its exit status to a file, because the harness cannot wait on a process it did not start.
Any miss, such as no process waiting, a stale one or one that died with its sandbox, falls back to the normal launch.
Keeping a warm process honest
A process that imports code before it knows its work inherits whatever that code did at import time. We traced every file and environment variable read during import. No per-turn credentials were read, but the runtime loaded its environment and configuration files, which the harness rewrites each turn. The warm process now reloads both after it receives the turn.
Two bugs showed up in testing. The agent ends a turn with a hard exit that skips normal shutdown, so our exit-status code never ran and every successful turn looked killed; the status is now recorded inside the exit path. And the warm process, unlike the guard process our normal launch uses, exited on the first termination signal, which could leave tools that ignore it running. The harness now kills whatever remains of the group a second later, as the guard does.
We then ran every path that ends a turn early in real chats: Stop, browser hand-off, browser switch and a sandbox restart. Each one cleaned up the warm process and its group. The restart test also found leftover socket files, which the harness now removes.
What we measured

In live chats, the median time to the first model request fell from 3.18 to 1.44 seconds in a plain chat and from 3.70 to 1.98 seconds in a chat with saved logins. Per-turn setup such as starting tool servers still runs, which is why the warm path does not reach zero. Every follow-up reports whether it used a warm process, and a configuration switch turns the feature off for running sandboxes on their next turn.
Pre-warming has precedent in Mercurial's chg, Python's preloaded forkserver and Android's Zygote. We also considered lazy imports, which leave Python start-up in place, and process snapshots such as AWS Lambda SnapStart, which repeat any random seeds or identifiers in every restored copy. A single-use warm process kept the per-turn contracts intact.
Taking this forward
The opening message of a chat still starts cold, because no earlier turn exists to prepare it. We also plan a build check that compares a warm turn with a normal one, so a runtime upgrade that adds import-time state is caught before it ships.
If you're building agents that run a process per turn, start with an import-time audit. Trace what your runtime reads before it knows its work, and decide what to replay.