google / ax

Google / AX

AX Warning We are still actively refining our core concepts, protocols, and specifications. We will likely to introduce major breaking changes prior to a stable release. AX 警告 我们目前仍在积极完善核心概念、协议和规范。在发布稳定版本之前,我们很可能会引入重大的破坏性变更。

Declare an agentic task with workspaces and gateway specifications. AX sandboxes it, wires up its workspace, fences its network, and helps running it at scale. AX is a high-throughput, declarative orchestrator to run billions of autonomous agent workloads in a cluster. It runs on top of Agent Substrate for sandboxed execution and is built to run billions of tasks per cluster. If you have used Kubernetes, ax will feel similar. 通过工作区(workspace)和网关(gateway)规范来声明一个智能体任务。AX 会对其进行沙箱隔离、挂载工作区、限制网络访问,并协助其大规模运行。AX 是一个高吞吐量的声明式编排器,旨在集群中运行数十亿个自主智能体工作负载。它基于 Agent Substrate 进行沙箱执行,专为每集群运行数十亿个任务而构建。如果你使用过 Kubernetes,会觉得 ax 非常熟悉。

# task.yaml
apiVersion: ax.io/v1alpha1
kind: Workspace
metadata:
  name: golang
spec:
  git:
    - repo: https://github.com/golang/go.git
      branch: "my-fix"
---
apiVersion: ax.io/v1alpha1
kind: Task
metadata:
  name: test
spec:
  workspaces:
    - name: golang
  goal: "Ensure that Go tool chain is available and is built from source"
  debug: true # lets you `ax ssh` into the sandbox

Then apply it, watch it come up, and look over the agent’s shoulder: 然后应用它,观察其启动过程,并查看智能体的运行状态:

ax apply -f task.yaml
ax watch task test
ax ssh test -- ls -al /workspace

Why? Agents are a new kind of workload. They are neither stateless microservices nor run-to-completion batch jobs. They accumulate state, need strict isolation, call out to model APIs and tool servers, and can burn money in a loop if nobody is watching. AX gives you four small primitives that handle all of that declaratively: 为什么? 智能体是一种新型工作负载。它们既不是无状态微服务,也不是运行即结束的批处理作业。它们会积累状态,需要严格的隔离,会调用模型 API 和工具服务器,如果无人监管,还可能在循环中消耗大量资金。AX 提供了四个小型原语,以声明式方式处理所有这些问题:

You want to…AX gives you
Run untrusted agent code in an isolated sandbox with CPU/memory limitsTask
Pre-wire Git repos, MCP servers, and skill packages so every agent starts warmWorkspace
Lock outbound traffic down to an explicit host allowlistGateway
Configure which LLM the platform itself uses, with credentials from a Kubernetes secretModel
你想要…AX 提供…
在具有 CPU/内存限制的隔离沙箱中运行不受信任的智能体代码Task
预先挂载 Git 仓库、MCP 服务器和技能包,使每个智能体都能“热启动”Workspace
将出站流量锁定到明确的主机白名单Gateway
配置平台使用的 LLM,并从 Kubernetes Secret 获取凭据Model

Pause an idle agent and pick up exactly where it left off: ax suspend / ax resume 暂停空闲的智能体并在中断处恢复:ax suspend / ax resume

Shell into a running agent to see what it is doing: ax ssh 进入正在运行的智能体以查看其行为:ax ssh

Everything is expressed as ax.io/v1alpha1 manifests and applied with a single command. 所有内容均以 ax.io/v1alpha1 清单表示,并通过单个命令应用。

Quick start / 快速开始

1. Install the CLI

go install github.com/google/ax/cmd/ax@latest

This puts the ax binary in $(go env GOPATH)/bin. Make sure that directory is on your PATH. 1. 安装 CLI 这会将 ax 二进制文件放入 $(go env GOPATH)/bin。请确保该目录已添加到你的 PATH 中。

2. Deploy the control plane You need a Kubernetes cluster, ko (brew install ko), a container registry your cluster can pull from, and a reachable Agent Substrate Control API (in-cluster default: api.ate-system.svc.cluster.local:443).

make deploy AX_IMAGE_REPO=<your-registry>

This deploys Redis, then builds and deploys the control plane images with ko. Everything lands in the ax-system namespace. 2. 部署控制平面 你需要一个 Kubernetes 集群、ko (brew install ko)、一个集群可拉取的容器镜像仓库,以及一个可访问的 Agent Substrate 控制 API(集群内默认地址:api.ate-system.svc.cluster.local:443)。 这会部署 Redis,然后使用 ko 构建并部署控制平面镜像。所有内容都将部署在 ax-system 命名空间中。

3. Run your first task

ax apply -f examples/task.yaml # Task + Workspace + Gateway + Model in one file
ax get tasks
ax watch task task123
ax ssh task123 -- ls -la /workspace
ax suspend task task123
ax resume task task123

3. 运行你的第一个任务 (如上所示,包含 Task + Workspace + Gateway + Model 的单文件应用、获取任务列表、监控任务、进入沙箱查看、挂起任务以及恢复任务。)

Want to see the whole lifecycle end to end? Run ./demo.sh. It applies a custom workspace, waits for readiness, runs commands over ax ssh, and suspends the task. 想要查看完整的生命周期吗?运行 ./demo.sh。它会应用一个自定义工作区,等待就绪,通过 ax ssh 运行命令,并挂起任务。

Documentation / 文档

  • Concepts: Learn what a Task, Workspace, Gateway, and Model each do, and how a task moves through phases and conditions. 概念:了解 Task、Workspace、Gateway 和 Model 的作用,以及任务如何经历各个阶段和条件。
  • Manifests: Write your own YAML, with an annotated example of every kind. 清单:编写你自己的 YAML,并参考每种类型的带注释示例。
  • Sandbox: See what the runner does on boot and what your command can rely on: metadata server, guest services, environment. 沙箱:查看运行器在启动时执行的操作,以及你的命令可以依赖的内容:元数据服务器、客户服务、环境等。
  • Runners: Understand the contract between the control plane and the task container, and build your own runner image to replace the default. 运行器:理解控制平面与任务容器之间的契约,并构建你自己的运行器镜像以替换默认镜像。
  • Networking: Reach a running task through the atenet router from the cluster, your laptop, or a gRPC client. 网络:通过 atenet 路由器从集群、你的笔记本电脑或 gRPC 客户端访问正在运行的任务。
  • Architecture: Understand how the control plane fits together, plus the API reference. 架构:了解控制平面的组成,以及 API 参考。
  • Development: Build, test, and ship changes to AX itself. 开发:构建、测试并发布对 AX 本身的更改。

CLI usage / CLI 使用

ax talks to the control plane over gRPC. It is deliberately kubectl-shaped: apply, get, describe, watch, delete, plus a few agent-specific verbs. ax 通过 gRPC 与控制平面通信。它刻意模仿了 kubectl 的风格:applygetdescribewatchdelete,以及一些智能体特有的动词。

Everyday commands / 日常命令

# Apply anything (multi-document YAML, file or stdin)
ax apply -f examples/task.yaml

# Tasks
ax get tasks
ax get tasks -a my-atespace
ax get task task123
ax describe task task123
ax watch task task123
ax suspend task task123
ax resume task task123
ax delete task task123

# Shell into the running sandbox
ax ssh task123
ax ssh task123 -- ls -la /workspace
ax ssh task123 -- python3 main.py

Works with kubectx / 与 kubectx 配合使用 ax follows your active Kubernetes context. Switch clusters and ax resolves and tunnels to that cluster’s control plane in the background. ax 会跟随你当前激活的 Kubernetes 上下文。切换集群后,ax 会在后台自动解析并隧道连接到该集群的控制平面。

kubectx staging-cluster
ax get tasks
kubectx prod-cluster
ax get tasks
# Or target a context without switching
ax --context=dev-cluster get tasks