Codex Fleet — Antigravity × Codex Delegation Guide
Codex Fleet turns Antigravity into the orchestrator (task decomposition, scoping, delegation, and acceptance review) while one or more configurable Codex agents run development work asynchronously and stream their live activity into a right-side Codex Fleet panel.
1. Core Capabilities & Architecture
- Configurable, decoupled backend (not tied to a single local Codex install):
local-app-server(default): spawns any configuredcodexbinary (command,codexHome,codexProfile,env) viacodex app-server --listen stdio://.remote-app-server: connects to a remote Codex App Server overws://,wss://, orunix://with optional Bearer token env var.local-exec: compatibility fallback for older Codex CLI versions (codex exec --json).
- Dual right-side Fleet panel surfaces reading the exact same shared daemon state:
- Sidecar Panel (
SIDECAR_UI_ENTRYPOINT_AUX_PANE): automatically receiveswindow.sidecar.conversationIdfrom Antigravity Desktop and switches tasks automatically when you switch conversations. Open via Overview > Plugins > Codex Fleet or a[Codex Fleet](sidecar://codex-fleet/fleet-panel/)pill. - MCP App Panel (
aux_pane&global): opened viacodex_open_panel, works even when sidecars are disabled, renders the same live Fleet UI, and updates in place.
- Sidecar Panel (
- Strict
(model, reasoning_effort)validation: checks livemodel/listbefore starting a thread and monitorsmodel/reroutedat runtime — refuses silent fallback and returns exact supported combinations on error. - Completion messaging back to the main conversation: when a Codex agent finishes, fails, or requests input (
awaiting_input), the Fleet daemon delivers a structured report directly to the owning Antigravity conversation viaagentapi send-message(and the panel also provides a manual Send to Chat button). - Resource-friendly lifecycle: Close (unload thread & reclaim idle Codex worker process), Archive (archive thread in Codex & hide from active roster), and Resume (restore any closed/archived Codex session with full context intact).
2. Standard Delegation Workflow (For the Main Antigravity Agent)
Step A — Discover available models & efforts (when needed)
If the user asks for available options, or before guessing a model/effort:
codex_discover()
This returns the active profile, live account models, default model/effort, and exact supportedReasoningEfforts per model.
Step B — Dispatch asynchronously (Fast-Dispatch Principle)
Keep the main session lightweight: read only the minimal files needed to scope the task, and dispatch multiple independent tasks in parallel in a single turn with codex_delegate_start. Do not spend main-session turns pre-debugging target repo build/runtime environments (e.g. missing compiled .so extensions or Python version overlays) — include a 1-line fallback instruction in prompt and let Codex investigate directly.
Call codex_delegate_start with a clear, scoped brief:
prompt: Clear, self-contained development or research task description.cwd: Absolute path to the target git repository / workspace.task_type:"research"(investigation, codebase analysis, independent verification, review) or"development"(coding, refactoring, bug fixes, tests; default).- Applies the user's configured
taskPresets.research/taskPresets.developmentfrom~/.gemini/antigravity/codex-fleet/config.json. - Factory defaults: account default model & effort,
sandbox="read-only"forresearch,sandbox="workspace-write"fordevelopment(customizable via ⚙ Config orcodex_fleet_config).
- Applies the user's configured
allowed_scope: Explicit list of allowed files/directories Codex may modify.acceptance_criteria: Required tests and checks Codex must run and pass.model&reasoning_effort: Omit to use the configuredtask_typepreset above, or pass exactly what the user requested (never silently alter them; ifcodex_delegate_startreturns a validation error, report the exact error and valid options to the user). Never create redundantprofilesinconfig.jsonjust to switch models.agent_name: Short descriptive name (e.g.boundary-tests,auth-fix) so multiple concurrent Codex agents are easy to distinguish in the Fleet panel.conversation_id: Auto-injected by the plugin'sPreToolUsehook; also pass your current conversation ID explicitly if calling outside hook scope.
Fast Recovery if MCP Returns connection closed
If a plugin hot-reload interrupts the Antigravity stdio MCP pipe (connection closed: calling "tools/call"), do NOT inspect plugin source code, logs, or processes. Retry once; if still closed, immediately use the built-in direct daemon CLI (shares the exact same Fleet Daemon, right-side panel, strict validation, and main-conversation notifications):
node ~/.gemini/config/plugins/codex-fleet/scripts/fleet-cli.mjs start \
--task-type research --agent-name verify-01 --cwd /path/to/repo \
--conversation-id "<current-conversation-id>" --prompt "..."
Supported CLI subcommands: discover, start, rerun, status, list, respond, cancel, close, archive, resume, config.
One-Step Model / Preset Switch (codex_delegate_rerun)
When the user wants to switch an existing agent to another task_type, model, or reasoning_effort, do not manually archive, edit profiles, and re-type the brief — call codex_delegate_rerun once:
codex_delegate_rerun(task_id="verify-01", task_type="research", extra_prompt="Focus on static verification if native binaries are missing.")
This strictly validates and launches the new agent first, then automatically archives (or closes) the previous agent.
Immediately after dispatch:
- Call
codex_open_panel(conversation_id="<current-conversation-id>")(or surface[Codex Fleet](sidecar://codex-fleet/fleet-panel/)if the sidecar is enabled and not yet open) so the right-side Fleet panel displays the live agent card and event stream. - Tell the user the
task_id,agent_name, effectivemodel&reasoning_effort, and confirm they can keep conversing while Codex runs.
Step C — Periodic progress polling in the main session
Use Antigravity's built-in schedule tool to poll at the configured interval (poll_interval_seconds returned by codex_delegate_start, default 30 seconds):
schedule(
DurationSeconds=30,
TimerCondition="never",
Prompt="Check Codex task <task_id> via codex_delegate_status(task_id='<task_id>'). If still running, summarize latest activity briefly and schedule the next 30s check. If completed, failed, cancelled, or awaiting_input, stop polling, inspect git diff & tests (or relay the question), and report to the user."
)
Polling stop rules:
- Stop scheduling further timers as soon as
statusiscompleted,failed,cancelled,closed,archived, orawaiting_input. - If
notification.sentis alreadytrue(meaning the Fleet daemon already delivered the completion message back to the main conversation viaagentapi send-message), avoid repeating the raw report — go straight to verifying the diff & test results.
Step D — Messaging, Steering, Interrupting, and Extracting Process Results
Every lifecycle tool (codex_delegate_status, codex_delegate_respond, codex_delegate_cancel, codex_delegate_close, codex_delegate_archive, codex_delegate_resume) accepts either the task_id or the agent's agent_name (e.g. lerp-feature):
- Answer
awaiting_input(approval or question):codex_delegate_respond(task_id="lerp-feature", decision="accept") # for approvals codex_delegate_respond(task_id="lerp-feature", text="<answer>") # for user_input - Steer a running agent mid-turn (without cancelling it):
codex_delegate_respond(task_id="lerp-feature", action="steer", text="Also cover negative zero.") - Continue messaging a completed / closed / archived agent (auto-resumes its Codex thread with full history intact):
codex_delegate_respond(task_id="lerp-feature", text="Add JSDoc comments to lerp() and re-run npm test.") - Interrupt a running agent (preserves thread & intermediate work so you can inspect or continue later):
codex_delegate_cancel(task_id="lerp-feature") - Extract intermediate process results at any time (reasoning summary, plan, intermediate messages, executed commands & outputs, partial file changes & unified diff):
codex_delegate_status(task_id="lerp-feature", include_diff=true, include_timeline=true)
Step E — Acceptance & Verification
Once Codex reports completed:
- Call
codex_delegate_status(task_id="<task_id>", include_diff=true)to review Codex's final message, command exit codes, and diff. - Independently verify in the repository (
git status,git diff, and running the relevant test suite) to confirm scope compliance and passing tests before accepting.
3. Resource Management: Close, Archive, and Resume
Running many concurrent Codex sessions keeps app-server threads loaded in memory. Encourage cleanup once a task is verified:
- Close (
codex_delegate_close): Unloads the thread from Codex (thread/unsubscribe) and immediately terminates idle localcodex app-serverchild processes when no live threads remain. Passtask_id="__idle__"to bulk-close all finished agents in one call. - Archive (
codex_delegate_archive): Unloads and archives the thread in Codex (thread/archive), moving the agent out of the active roster into the Archived filter tab. - Resume (
codex_delegate_resume): Restores anyclosed,archived,completed,failed, orcancelledagent back into the live Fleet viathread/unarchive+thread/resume, preserving its full prior Codex conversation context! You can optionally pass a follow-uppromptand/or validatedmodel/reasoning_effortoverride.
All three actions are also available as one-click buttons (Close, Archive, Resume, Close Idle) directly inside the right-side Codex Fleet panel.
4. Configuring Local & Remote Codex Backends & Language
You can configure Codex Fleet via the ⚙ Config / 配置 button in the right-side panel, by calling codex_fleet_config(patch={...}), or by editing ~/.gemini/antigravity/codex-fleet/config.json:
language:"auto"(follow system/host locale),"zh-CN"(Simplified Chinese), or"en"(English). Applies to both the right-side Fleet panel and completion reports sent back to the main Antigravity conversation.taskPresets: Default model,reasoningEffort, andsandboxper task type (researchfactory default: account default /read-only;developmentfactory default: account default /workspace-write). Customizable in the panel's ⚙ Config / 配置 modal or viacodex_fleet_config.
Example: Add a Remote Codex App Server profile
{
"language": "auto",
"activeProfile": "remote-workstation",
"pollIntervalSeconds": 20,
"maxActiveAgents": 4,
"strictModelValidation": true,
"autoNotifyMainConversation": true,
"autoReclaimIdleProcess": true,
"profiles": {
"remote-workstation": {
"label": "Remote GPU Devbox",
"transport": "remote-app-server",
"remoteUrl": "ws://10.0.0.12:4500",
"authTokenEnv": "CODEX_REMOTE_TOKEN",
"defaultSandbox": "workspace-write",
"defaultApprovalPolicy": "never"
}
}
}
Example: Add a Secondary Local Codex Account / Custom Binary
{
"profiles": {
"work-codex": {
"label": "Work Account Codex",
"transport": "local-app-server",
"command": "/usr/local/bin/codex",
"codexHome": "/Users/you/.codex-work",
"defaultModel": "gpt-6.1-terra",
"defaultReasoningEffort": "high"
}
}
}
5. MCP Tool Quick Reference
| Tool | Purpose |
|---|---|
codex_discover | Query live models & supported reasoning_effort values from the active profile |
codex_delegate_start | Start an async Codex task with strict (model, reasoning_effort) validation |
codex_delegate_status | Read live status, events, commands, diff stats, and effective config |
codex_delegate_respond | Answer awaiting_input, approve/decline requests, steer running turn, or follow up |
codex_delegate_cancel | Interrupt a running turn cleanly |
codex_delegate_close | Unload thread & reclaim idle worker process (preserves thread for resume) |
codex_delegate_archive | Archive thread & hide from active fleet (preserves thread for resume) |
codex_delegate_resume | Restore a closed/archived/finished Codex session with full context |
codex_delegate_rerun | Re-run an existing task in one step with a new task_type, model, reasoning_effort, or extra guidance |
codex_delegate_list | List agents for the current Antigravity session (or all sessions) |
codex_fleet_config | Read or patch backend profiles, polling interval, and notification policies |
codex_open_panel | Open/refresh the MCP App right-side Fleet panel (aux_pane / global) |