把智能体请回本机:谷歌 Antigravity SDK 的离线路线 / Bringing Agents Home: Google’s Offline Route

2026年11月7日 · AOAI AI

长期以来,本地部署大模型的争论总绕着一个问题打转:这东西到底跑不跑得起来?谷歌 9 月 23 日的一则公告换了个问法:跑起来之后,能不能真的替人干活?Antigravity SDK 新增了对本地模型的支持,首个适配对象是 Gemma 4 26B A4B,底层依托 Google AI Edge 的 LiteRT 运行时。这意味着原本依赖云端的智能体能力,现在可以在一台断网的机器上完成。

For years, the argument over running large models locally circled one question: can the thing even run? A Google announcement on September 23 asks something different: once it runs, can it actually do work for you? The Antigravity SDK now supports local models, with Gemma 4 26B A4B as the first supported model, built on the LiteRT runtime from Google AI Edge. Agent capabilities that used to depend on the cloud can now work on a machine with no network connection.


先说门槛。官方给出的硬件建议是显存或统一内存超过 24GB,对应的大概是高端独立显卡,或者内存充裕的苹果芯片笔记本。这个数字比很多教程含糊的”配置不要太差”有用得多,买不买设备、够不够用,一眼就能判断。至于为什么要费这个劲,官方给了四条理由:没有 API 账单和调用频率限制;代码与请求不出本机;网络差甚至没网也能工作;还可以与云端模型搭配,把贵的 token 留给真正需要的环节。

Start with the entry fee. Google recommends more than 24GB of VRAM or unified memory, which points to a high-end discrete GPU or an Apple-silicon laptop with plenty of RAM. That is far more useful than the vague “don’t use a weak machine” found in many tutorials, because you can decide at a glance whether your hardware qualifies. As for why bother, Google offers four reasons: no API bills or rate limits, code and prompts that never leave your machine, workflows that survive a poor or absent connection, and the option to pair local models with cloud ones so expensive tokens go only where they matter.


动手的过程比想象中短。先建一个 Python 虚拟环境并激活,然后执行 pip install google-antigravity litert-lm,前者是 SDK,后者是管理本地模型的命令行工具。再用 litert-lm import 从 Hugging Face 上 litert-community 名下的 Gemma 4 仓库拉取量化后的模型文件,并给它起个本地名字 gemma4-26b。导入完成,模型就躺在用户目录下的 .litert-lm/models/gemma4-26b/ 里,之后的代码只需要指向这个位置。

The setup is shorter than you might expect. Create and activate a Python virtual environment, then run pip install google-antigravity litert-lm: the first package is the SDK, the second a command-line tool for managing local models. Next, litert-lm import pulls the quantized Gemma 4 files from the litert-community repository on Hugging Face and registers them under the local name gemma4-26b. After the import, the model sits under .litert-lm/models/gemma4-26b/ in your home directory, and your code only needs to point at that location.


最小的示例脚本只有寥寥几十行。你用 LiteRTAgentConfig 指定模型路径,在异步环境里创建 Agent,抛出一个问题,比如”当前目录里有什么文件”,答案便一个 token 一个 token 地流出来。配置后面追加的 .lightweight() 会切到更省资源的档位,官方的两个例子都这么写。有一点要提前心里有数:第一次推理可能要等几分钟,脚本里官方自己也留了提示,别把等待当成死机。

The smallest sample script is only a few dozen lines. You point LiteRTAgentConfig at the model path, create an Agent inside an async context, and ask a question such as “what files are in the current directory,” and the answer streams out token by token. The .lightweight() call appended to the configuration switches to a less demanding profile, and both of Google’s examples use it. One thing to expect: the first inference can take several minutes, and the script itself carries a note saying so, so don’t mistake the wait for a crash.


真正体现思路的是第一个演示,官方称之为 Architect-Builder 模式,也就是”架构师加施工队”。云端的大模型只负责拆解任务,本地的一群 Gemma 4 26B 负责在 GPU 上干活。任务是审计并修补 auth.py、billing.py、database.py 三个有漏洞的模块。云端全程只看到文件名和任务描述,源码一行没出门,整个过程只消耗了 95 个 token。

The first demo is where the idea really shows. Google calls it the Architect-Builder pattern: a cloud model only breaks the task down, while a group of local Gemma 4 26B instances does the work on the GPU. The job is to audit and patch three vulnerable modules, auth.py, billing.py and database.py. The cloud sees nothing but file names and a task description, not a single line of source leaves the machine, and the whole exchange costs just 95 tokens.


施工队的流程也值得一看:先复现漏洞,再写候选补丁,接着让模型批评自己的补丁,最后跑回归测试确认没有改坏别的东西。官方给出的统计是,总共 3,322 个 token,其中 97.2% 在本地离线消耗,最终拿到一组通过验证的修复。换句话说,最贵的那部分智力用在了规划上,最耗量的那部分体力活留给了自己的显卡,成本结构因此被彻底改写。

The builders’ routine is worth a look too: reproduce the bug, draft candidate patches, have the model critique its own patch, then run regression tests to confirm nothing else broke. Google’s tally is 3,322 tokens in total, 97.2% of them consumed locally and offline, ending in a set of validated fixes. In other words, the most expensive intelligence is spent on planning while the bulk of the labor falls to your own graphics card, which rewrites the cost structure.


第二个演示更接地气。官方只给模型一句需求:用 psutil 和 rich 写一个终端实时仪表盘,显示 CPU、内存,以及内存占用前五的进程,存成 monitor.py,再生成依赖清单并自己测试。模型独立完成了这一整套。这份脚本比前一份多了两个参数:workspaces 把智能体限制在指定的工作目录,policies 则决定它的权限,示例里用的是全部放行。放到真实项目里,这两个开关恰恰是最该谨慎设置的地方。

The second demo is more down to earth. Google hands the model a single request: build a live terminal dashboard with psutil and rich showing CPU, memory and the five most memory-hungry processes, save it as monitor.py, produce a dependency list, and test it. The model completes the whole chain on its own. This script adds two parameters over the first: workspaces confines the agent to a chosen working directory, and policies governs its permissions, which the sample sets to allow everything. In a real project, these two switches are exactly where caution belongs.


如果你不想用 LiteRT,也不必改动已有的编排。SDK 通过 LocalOpenAIAgentConfig 兼容任何遵循 OpenAI 接口的本地推理服务,Ollama、LM Studio 和 vLLM 都在官方点名之列,换后端时工具与工作流保持原样。想继续深入,可以去看 GitHub 上的 antigravity-sdk-python 仓库,以及 Google AI Edge 的 LiteRT-LM 文档。

If you’d rather not use LiteRT, your existing orchestration need not change. Through LocalOpenAIAgentConfig, the SDK works with any local inference server that follows the OpenAI interface, and Google names Ollama, LM Studio and vLLM; tools and workflows stay as they are when you swap backends. To go deeper, see the antigravity-sdk-python repository on GitHub and the LiteRT-LM documentation from Google AI Edge.


回头看,这次更新的价值不在某个新模型,而在把一条可复制的路线摆了出来:硬件有标准,步骤能照做,账目算得清。当然,本地模型能否在你的真实代码库里达到演示的效果,还得自己试过才知道。如果让你挑一个环节先搬回本机,你会选哪一个?

Looking back, the value of this update lies not in a new model but in a route you can copy: there is a hardware standard, steps you can follow, and accounts that add up. Whether a local model matches the demos on your own codebase, of course, only a trial will tell. If you could bring just one stage of your workflow back onto your own machine first, which would it be?


说明:文中事实均取自你提供的文章与官方公告,我没有另行核实具体数字。篇幅按中文字数加英文单词数合计约 2500 估算,如需精确到字数,我可以再调整。