結論先說
- 絕大多數場景首選
types.TemplatedSystemInstructions:覆蓋identity並追加SystemInstructionSection的同時,完整保留 SDK 預設腳手架與環境上下文。 types.CustomSystemInstructions會旁路全部預設腳手架:傳入原始text後屏蔽環境提示,僅適合需要 100% 原生 Prompt 控制的高級場景。- 角色模組化應把「指令小節」與「工具權限」綁定:例如安全審計員綁定
BuiltinTools.read_only(),避免審查時意外寫盤。 - 通過
types.SubagentConfig隔離多角色上下文:每個子代理可配置獨立system_instructions、tools與模型參數。 - 複雜多角色編排測試依賴高額算力池:在 IDE 調優角色規範時推薦 Gemini Google AI Ultra 充值指南 與 Gemini Google AI Ultra 5x 人工 iOS。

圖:本站根據 Antigravity SDK Personas 文檔 整理的示意圖
本文根據 Google Antigravity SDK 官方文檔整理,資料核對於 2026-12-03。配圖為本站整理的示意圖,不是介面截圖。本站(bigolab.com)由益陽市赫山區必高科技有限公司獨立運營,是獨立第三方服務商,不是 Google 官方網站。
適用於誰
- 把系統提示詞硬編碼成大段字符串、難以複用與評審的 Python 開發者;
- 用了
CustomSystemInstructions後發現 Agent 丟失工作區認知或工具調不起來的工程師; - 希望把安全審計、PR 審查等角色與最小工具集打包進子代理的團隊。
一、三種系統指令注入方式與模組化代碼
| 指令形態 | 保留預設腳手架 | 結構化分段 | 適用場景 |
|---|---|---|---|
純字符串 system_instructions="..." | 是(基礎) | 無 | 輕量單文件原型 |
TemplatedSystemInstructions(推薦) | 完整保留 | SystemInstructionSection | 代碼審查、安全審計主力方案 |
CustomSystemInstructions | 完全旁路 | 原始文本 | 極簡定製格式或屏蔽預設上下文 |
import asyncio
from google.antigravity import Agent, CapabilitiesConfig, LocalAgentConfig, types
from google.antigravity.types import BuiltinTools
def build_auditor_si() -> types.TemplatedSystemInstructions:
return types.TemplatedSystemInstructions(
identity="You are a strict Application Security Auditor.",
sections=[types.SystemInstructionSection(title="audit_scope", content="- 排查硬編碼密鑰與危險反序列化,僅輸出路徑與建議。")],
)
async def main() -> None:
auditor = types.SubagentConfig(
name="security_auditor",
description="只讀安全審計子代理。",
system_instructions=build_auditor_si(),
capabilities=CapabilitiesConfig(enabled_tools=BuiltinTools.read_only()),
)
async with Agent(LocalAgentConfig(subagents=[auditor])) as agent:
res = await agent.chat("委派 security_auditor 審計 src/auth。")
print(await res.text())
if __name__ == "__main__":
asyncio.run(main())
人工核對要點:
- 需調工作區工具的角色均採用
TemplatedSystemInstructions; - 每個
SystemInstructionSection的title清晰表達約束主題; - 只讀審核角色已通過
BuiltinTools.read_only()收窄寫權限。
二、Custom 指令切換邊界與子代理選型

圖:本站根據 Antigravity SDK Personas 文檔 與 Subagents 文檔 整理的示意圖
僅當接入極小上下文的本地模型或要求完全掌控原始 Prompt 時才用 CustomSystemInstructions;包含多步操作規程的領域手冊應放到 skills_paths 的 SKILL.md 中,保持 SystemInstructionSection 精煉。
訂閱與開通提示:多角色協同調測推薦 Gemini Google AI Ultra 5x 人工 iOS 或 Gemini Google AI Ultra 20x 人工 iOS;需獨立測試帳號可看 Google 帳號與訂閱指南 或選 谷歌電郵成品號(質保 3 天首登、封號不在質保範圍,須遵守 Google 服務條款);多模型對比可搭 Claude Max 5x iOS 自助充值。全站以商品頁實時標價為準,標價不含稅,開具國內增值稅發票另付 6% 稅費;單獨申請自定義明細電子收據免費,企業批量支持籤中文合同並對公結算。
常見問題
問:換成 CustomSystemInstructions 後不會用工作區工具了怎麼回事?
答:CustomSystemInstructions 會旁路預設 SDK 腳手架與環境資訊,需要內置工程能力時請改回 TemplatedSystemInstructions。
問:長段業務 SOP 放 SystemInstructionSection 還是用 Skills?
答:人設與輸出格式放 SystemInstructionSection,長步驟領域規程建議通過 skills_paths 掛載 SKILL.md。
問:不同子代理 Persona 能綁定隔離的自定義工具嗎?
答:可以,SubagentConfig(tools=[...]) 註冊的工具會自動限定在該子代理作用域內。
問:團隊購買訂閱怎麼開 6% 增值稅發票與對公簽約?
答:在 AI 訂閱與帳號服務總覽 或 Gemini Google AI Ultra 5x/20x 充值指南 選 Gemini Google AI Ultra 5x 人工 iOS。全站以商品頁實時標價為準,標價不含稅,開具國內增值稅發票另付 6% 稅費;單獨申請自定義明細電子收據免費。本站明示質保訂閱、不質保封號,請遵守服務商條款合規使用。
相關教學
- Antigravity 2.0 混切 Gemini 4 與 Claude 模型省額度指南:長倉檢索與複雜重構分工策略
- Antigravity 報錯 Agent terminated due to error 怎麼修:Reset onboarding、上下文過載與插件衝突
- Antigravity 2.0 桌面端額度消耗對比與團隊採購:Pro 與 Ultra 差異、刷新機制及 6% 增值稅發票說明
- Antigravity 使用時報錯執行被中斷怎麼辦:跨目錄讀寫拒絕、外網訪問攔截與舊版崩潰修復
0 條評論
還沒有評論,來搶沙發~