Skip to content

armgit / ax

Public Imported from GitHub
0

Agent Executor (AX) is Google's open agentic orchestration runtime

Go

Minimize the AX Docker image (1.35GB -> 360MB) for faster resumption on Substrate (#208)

Jaana Dogan4aa817cccd77
diff --git a/cmd/ax/Dockerfile b/cmd/ax/Dockerfile
index 3db2a25..bc41ed5 100644
--- a/cmd/ax/Dockerfile
+++ b/cmd/ax/Dockerfile
@@ -32,13 +32,18 @@ COPY . .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -tags=harness -o /out/ax ./cmd/ax
-# --- Stage 2: comprehensive runtime (Debian + Python + Antigravity) -----------
-# Python image: a full Debian base (buildpack-deps) that
-# already ships bash, git, curl, wget, ca-certificates, build-essential, and the
-# common CLIs (find/ps/less/grep/sed/...).
-FROM python:3.13
+FROM python:3.13-slim
WORKDIR /ax
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends \
+ ca-certificates \
+ curl \
+ less \
+ procps \
+ wget \
+ && rm -rf /var/lib/apt/lists/*
+
# Antigravity runtime deps, installed from PyPI at build time.
COPY python/antigravity/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
diff --git a/manifests/README.md b/manifests/README.md
index e04fd43..8f39378 100644
--- a/manifests/README.md
+++ b/manifests/README.md
@@ -1,38 +1,16 @@
# AX Harness Deployment on Kubernetes
> [!WARNING]
-> 🚧 **The `harness` deployment path is under active development.**
>
> This path is experimental and incomplete: the manifests, scripts, and
> runtime behavior will change and may break without notice.
This directory contains Kubernetes manifests and configurations to deploy
-and verify the AX `harness` configuration path on Kubernetes using Agent
-Substrate.
+and verify the AX on Kubernetes using Agent Substrate.
The target Kubernetes cluster is assumed to have
[Agent Substrate](https://github.com/agent-substrate/substrate) installed.
-### Substrate compatibility
-
-AX pins [Agent Substrate](https://github.com/agent-substrate/substrate) in
-`go.mod`, and the **ateom** worker image is built from that pinned version. The
-cluster's substrate **CRDs and control plane** must be compatible with the
-manifest AX applies.
-
-When installing substrate, keep three things aligned: the ax `go.mod` pin = your
-local substrate checkout = the cluster's installed substrate.
-
-```bash
-# Get AX's pinned substrate commit:
-commit=$(go list -m -f '{{.Version}}' github.com/agent-substrate/substrate | sed 's/.*-//')
-echo "$commit" # e.g. fe93d160a1df
-
-# Check it out on a normal branch in your substrate clone (avoids a detached HEAD):
-git -C <substrate> fetch origin
-git -C <substrate> switch -C ax-pinned "$commit"
-```
-
---
## 🚀 Deploying to Agent Substrate
@@ -45,17 +23,14 @@ git -C <substrate> switch -C ax-pinned "$commit"
The installation script builds the required images and applies the resolved
manifests to your cluster:
-- the comprehensive **ax** image, built from `cmd/ax/Dockerfile` with Docker or
- Podman (the `harness`-tagged Go `ax` binary plus the Antigravity Python sidecar
- on a Debian base). The ax-server runs `ax serve`; the harness actor runs
- `ax harness`, which forks the sidecar;
+- the comprehensive **ax** image, built from `cmd/ax/Dockerfile`,
- the **ateom-gvisor** worker image, built with `ko` from the `go.mod` pinned
substrate module.
#### Build prerequisites
-The ax image bundles the antigravity SDK and its `localharness` binary,
-installed from PyPI at build time. The image targets the cluster's **linux/amd64**
+The ax image bundles the antigravity SDK, installed from PyPI at build time.
+The image targets the cluster's **linux/amd64**
nodes and is built with `--platform linux/amd64`.
You also need a container engine to build and push the ax image. The script
@@ -91,8 +66,6 @@ export BUCKET_NAME="snapshot-substrate-test-$PROJECT_ID"
### 2. Port-Forward Services
-The `harness` path has no Envoy router or `Service`; connect directly to the `ax-server` `ReplicaSet`:
-
```bash
# Port-forward the ax-server ReplicaSet
kubectl port-forward -n ax rs/ax-server 8494:8494
@@ -153,3 +126,23 @@ List the pods running in the `ax` namespace:
# Add `-o wide` to see node/IP assignments, or `-w` to watch status changes.
kubectl get pods -n ax
```
+
+## Substrate compatibility
+
+AX pins [Agent Substrate](https://github.com/agent-substrate/substrate) in
+`go.mod`, and the **ateom** worker image is built from that pinned version. The
+cluster's substrate **CRDs and control plane** must be compatible with the
+manifest AX applies.
+
+When installing substrate, keep three things aligned: the ax `go.mod` pin = your
+local substrate checkout = the cluster's installed substrate.
+
+```bash
+# Get AX's pinned substrate commit:
+commit=$(go list -m -f '{{.Version}}' github.com/agent-substrate/substrate | sed 's/.*-//')
+echo "$commit" # e.g. fe93d160a1df
+
+# Check it out on a normal branch in your substrate clone (avoids a detached HEAD):
+git -C <substrate> fetch origin
+git -C <substrate> switch -C ax-pinned "$commit"
+```
diff --git a/python/antigravity/harness_server.py b/python/antigravity/harness_server.py
index d592027..911914f 100644
--- a/python/antigravity/harness_server.py
+++ b/python/antigravity/harness_server.py
@@ -304,6 +304,25 @@ def enhance_config_from_env(config) -> None:
if skills_dir not in config.skills_paths:
config.skills_paths.append(skills_dir)
+def resolve_localhost():
+ """Ensure `localhost` resolves to 127.0.0.1.
+
+ Substrate actors run under gVisor with no runtime-injected /etc/hosts.
+ The antigravity SDK dials localharness at ws://localhost:<port>/
+ and Python's resolver needs `localhost` in /etc/hosts.
+ """
+ try:
+ try:
+ with open("/etc/hosts", "r") as f:
+ if "localhost" in f.read():
+ return
+ except FileNotFoundError:
+ pass
+ with open("/etc/hosts", "a") as f:
+ f.write("127.0.0.1\tlocalhost\n")
+ except OSError as e:
+ print(f"WARNING: could not ensure localhost in /etc/hosts: {e}", file=sys.stderr)
+
def main():
parser = argparse.ArgumentParser(description="Antigravity gRPC Harness Server")
@@ -313,6 +332,10 @@ def main():
global loaded_config
enhance_config_from_env(loaded_config)
+
+ # This is a hack, on Agent Substrate /etc/hosts end up not
+ # having this entry even if it's the OCI image.
+ resolve_localhost()
asyncio.run(serve(args.host, args.port))