Skip to main content
Glama

English | 简体中文

codex-antigravity-duet: Codex and Antigravity as a duet

duet is a small local tool that lets two AI coding agents, OpenAI Codex and Google Antigravity, hand tasks to each other, discuss, leave each other notes, and share config. It is an MCP server installed on both sides. Work one agent hands to the other shows up in both apps, where you can open it and keep chatting.

Use it to call Codex from Antigravity, or Antigravity from Codex: get a second opinion, have one agent review the other's code, or delegate a whole task. Think of it as a Codex–Antigravity bridge: one MCP plugin that connects the OpenAI Codex app or CLI with the Google Antigravity app (Gemini and the other models it offers) or its CLI, agy.

Unofficial project, not affiliated with OpenAI or Google. Codex and Antigravity are their respective companies' products.

Feature

What it does

Antigravity → Codex

Say "ask Codex to review …" in Antigravity. duet starts a Codex conversation in the background, and the result comes back to Antigravity on its own.

Codex → Antigravity

Say "hand this to Antigravity …" in Codex. duet has the Antigravity app start a conversation for it, and the result comes back to Codex.

Visible in both apps

Hand work to Antigravity from the Codex project "111", and the conversation appears in the Antigravity app's "111" project (and the other way round). Open it to watch the whole run or keep chatting. If the other app has no project for that folder yet, one is created.

Multi-round discussion

task_followup continues the same conversation; the other agent remembers what was said, so the two can argue and correct each other.

Round limit

After 5 rounds in one conversation (configurable), duet stops and the agent must report to you and ask whether to go on; only your OK buys another 5 rounds. Two AIs cannot talk in circles until your tokens are gone.

Delegate, review, redo

One agent has the other write code in a separate git worktree and gets back the diff to review. Not good: send it back to redo in the same worktree and conversation. Good: one call brings it into the project.

Model and thinking level

The first handoff lists the other side's models and thinking levels for you to choose; the choice is remembered, and you can switch any time.

Mailbox

Short notes between the two agents, no task attached.

Config sync

MCP servers, skills and rule files (AGENTS.md / GEMINI.md) synced between the two, previewed before anything is written, fully undoable.

Highlights:

  • Never touches your login: Codex runs through the official codex app-server interface (the one the Codex app and the VS Code extension use). Antigravity runs through the local interface the app opens for its own client. That one is not publicly documented and may change when Antigravity updates; when it fails, or the app is closed, duet falls back to the official CLI agy -p (that conversation is then not shown in the app).

  • No approval clicking: nobody is watching a handed-over task, so it never stops to wait for you:

    • Codex: read-only tasks run in the read-only sandbox, editing tasks in the workspace-write sandbox, with no approval prompts.

    • Antigravity, editing tasks: the app's "Auto" permission preset; Antigravity's own policy allows safe actions, and anything that would ask a human is declined automatically.

    • Antigravity, read-only tasks: every command asks first; duet approves only commands that just read (ls, cat, grep, find, git log/diff/show …) and declines the rest, and the result lists what was declined.

    • Codex no longer asks before each call to duet's tools.

  • Read-only by default: the other agent changes files only when you said it may. Every task that changes files reports exactly which files and the diff (your own uncommitted changes are never counted as its work).

  • Tasks are not lost: each task runs in its own background process and its result goes into a local database. An MCP call timing out, or the chat being closed, does not matter.

  • No ping-pong, no endless loops:

    • A session that was handed a task cannot hand work on: in Codex, duet is switched off for it; in the Antigravity app, duet declines that conversation's calls to its tools. Even if you set duet to "always allow" in the app, duet recognizes calls coming from a conversation it started and refuses them.

    • One conversation goes at most 5 rounds (change it with duet rounds <N>), then stops: the agent must report to you and ask; if you say go on, it can ask for 5 more rounds, quoting your words. Your own duet followup in the terminal is never limited.

  • Handles mismatched versions and models: picks the newest Codex on the machine (including the one inside the desktop app), so models the desktop app can use work here too.

Install

Requires Node 22.13+, Codex (the CLI or Codex in ChatGPT.app), and the Antigravity app. Antigravity's official CLI agy is optional: it is used only when the app is not running.

  1. Install dependencies:

npm install
  1. (Optional) Install the Antigravity CLI as a fallback for when the app is closed:

curl -fsSL https://antigravity.google/cli/install.sh | bash

agy usually reuses the Antigravity app's sign-in; if a handoff says you need to sign in, run agy once in a terminal.

  1. Install duet on both sides:

node bin/duet.js install

install does three things:

  • Adds a marked [mcp_servers.duet] block at the end of ~/.codex/config.toml (backed up to ~/.duet/backups/ first; your own content and comments are left alone), with default_tools_approval_mode = "approve", so Codex does not ask before every duet call.

  • Adds a marked rule block at the end of ~/.codex/AGENTS.md: when the user mentions Antigravity, use duet.

  • Creates the Antigravity plugin ~/.gemini/config/plugins/duet/ (MCP server + rules), which Antigravity loads on its own, without a restart.

Then open a new Codex conversation and you are set. Check the setup:

node bin/duet.js status

To use the duet command from any folder, run npm link.

Related MCP server: mcp-cli-tools

Update

After pulling a new version:

git pull
npm install
node bin/duet.js install

install is safe to run again: it refreshes duet's rules on both sides to the new version and leaves your own config alone. Then:

  • Antigravity: restart duet in its MCP servers (or restart the app) so the new code runs.

  • Codex: open a new conversation.

Upgrading from cxag: this project used to be called cxag. After updating, run node bin/duet.js install once as usual. It will:

  • move your tasks, messages, chosen models and round limit to ~/.duet;

  • replace what the old version wrote into the Codex config, AGENTS.md and the Antigravity plugin with duet's;

  • keep the old ~/.cxag folder, because unapplied isolated worktrees (git worktrees) live there; apply / discard keep working. Delete it once you are done with them.

Then restart Antigravity's MCP servers (or the app) so it stops the old cxag server and starts duet, and open a new Codex conversation.

Using it from the agents

Just talk normally; you never need to say "duet":

  • In Antigravity: "Ask Codex to review the src/ folder"

  • In Codex: "Have Antigravity look at what this project does, then discuss with it whether the project makes sense"

  • Discussion: "Have Codex review the paper in latex/; judge each point it makes, discuss the ones you disagree on for 2–3 rounds, then give me a summary"

  • Say so when files may change: "Have Codex fix this bug; it may edit files"

  • Delegate and review: "Have Codex implement login; you review it, send it back if it's not good, and merge it when it is"

  • Notes: "Leave Codex a note: the API changed", "Check the inbox"

Tools:

Tool

What it does

ask_codex (in Antigravity) / ask_antigravity (in Codex)

Hand a task to the other side; returns a task_id at once. Read-only by default; allow_edits: true edits the project directly, isolate: true works in a separate git worktree

task_wait

Wait for the result (up to 10 minutes per call; call again if it is not done)

task_followup

Continue the same Codex thread / Antigravity conversation, for multi-round discussion. Past the round limit it needs user_approval (your words agreeing to go on)

codex_models / antigravity_models

List the other side's models and thinking levels, and the current choice

set_codex_model / set_antigravity_model

Save the model and thinking level you chose (default = the other side's own default)

task_apply / task_discard

After review, bring an isolated worktree's changes into the project / drop them

task_list / task_cancel

List or cancel tasks

send_message / read_inbox

Notes between the two agents

bridge_status

Check that both sides are ready

The first time a duet tool is called in the Antigravity app, the app may ask whether to allow it; choose "Always allow".

Choosing a model and thinking level

  • First handoff: instead of starting, it lists the other side's models and thinking levels for you to choose (or "default" for that side's own default). The choice is remembered and shared by both apps and the CLI.

  • To switch: just say "switch to gpt-6.2-sol", "set thinking to high", "use Claude for Antigravity"; the agent changes it, and later tasks and ongoing discussions use the new choice.

  • Just this once: say "use xxx this time"; only that task is affected.

  • A model or thinking level the other side does not support is refused right away, with the options listed.

  • Codex's thinking level is a separate setting (low / medium / high / xhigh / max / ultra, depending on the model); most Antigravity models carry the level in their name (e.g. gemini-4-neon-high), so pick that one.

From the command line:

duet models --for codex                          List Codex's models, thinking levels and the current choice
duet model --for codex gpt-6.2-sol --effort high Choose
duet model --for antigravity default             Back to Antigravity's default

Delegate, review, redo

You: "Have Codex implement X; you review it and send it back until it's good"
Antigravity ──ask_codex(isolate)──▶ Codex writes in a separate git worktree ──▶ result + diff
Antigravity reviews the diff
   ├─ not good ──task_followup("change this to …")──▶ Codex redoes it, same worktree, same conversation ──▶ new diff ──▶ review again
   └─ good ──task_apply──▶ changes land in your project (working tree only; nothing staged or committed)
  • The isolated copy is a git worktree of the project's current commit (HEAD), in ~/.duet/jobs/<task_id>/worktree. Your uncommitted changes are not in it, and nothing overwrites them.

  • Before applying, duet checks that the patch applies cleanly; if you changed the same lines meanwhile, it refuses and keeps the worktree so you can decide.

  • Folders that are not git repositories cannot use isolate mode, and in direct-edit mode there is no diff to show, only the other agent's account.

  • It works the other way round too: in Codex, say "have Antigravity write it, you review".

Command line

duet delegate --to codex|antigravity [--cwd DIR] [--wait SECS] [--allow-edits | --isolate] [--model M] [--effort E] "task"
duet tasks                     Recent tasks
duet task <id> [--wait SECS]   Show / wait for one task
duet followup <id> [--allow-edits] "more"
duet apply <id>                Bring an isolated task's changes into the project
duet discard <id>              Drop an isolated task's changes
duet cancel <id>
duet rounds [N]                Show / set the rounds per conversation (default 5)
duet send --to codex "note"
duet inbox --as antigravity

Config sync

node bin/duet.js sync

A preview by default; nothing is written. When it looks right, add --apply:

node bin/duet.js sync --apply

Options: --from codex|antigravity|both, --only mcp,skills,rules, --exclude name,name.

Direction

Reads

Writes

Codex → Antigravity

[mcp_servers] in config.toml, ~/.codex/skills, ~/.codex/prompts, ~/.codex/AGENTS.md

the duet plugin (mcp_config.json, skills/, rules/)

Antigravity → Codex

~/.gemini/config/mcp_config.json, ~/.gemini/config/skills, GEMINI.md / AGENTS.md

duet's blocks in config.toml and ~/.codex/AGENTS.md, ~/.codex/skills (marked with .duet-synced)

  • The Codex app's internal servers (computer-use, node_repl …) are skipped.

  • Name clashes never overwrite: MCP servers get a prefix (codex-xxx / ag-xxx), skills are skipped.

  • What was synced over is never synced back. Secrets are never printed.

If you only need these two tools in sync, duet is enough. To manage rules and MCP across many tools (Cursor, Claude Code …), see rulesync.

Uninstall

node bin/duet.js uninstall

Removes everything duet wrote: the blocks in config.toml and AGENTS.md, the Antigravity plugin, synced skills. Your own config is back as it was. --purge also deletes task records, messages and backups (~/.duet/).

How it works

 Antigravity agent ──MCP──┐                        ┌──MCP── Codex agent
                          ▼                        ▼
                duet mcp --as antigravity     duet mcp --as codex
                          │                        │
                          └───── ~/.duet/hub.db ───┘   (SQLite: tasks + mailbox)
                                    │       │
    ┌───────────────────────────────┘       └───────┐
    ▼                                               ▼
  To Codex: a background process                  To Antigravity: a background process
  runs codex app-server                           drives the Antigravity app
  shown in the Codex app's project                shown in the Antigravity app's project
  read-only or workspace-write sandbox            app closed: agy -p, not shown in the app
  • The two agents exchange only two things: the task handed over and the other agent's final answer; the sender does not see the steps in between. To watch them, open that conversation in the other app; full logs are also kept in ~/.duet/jobs/<task_id>/. duet itself reads the approval requests in Antigravity conversations, to approve or decline them.

  • Multi-round discussions continue the other side's same conversation (Codex thread / Antigravity conversation); the other side keeps the context, and every round is visible in its app.

  • Projects follow folders: the conversation goes into the other app's project whose folder contains the task's cwd (the innermost one); if there is none, a project named after the folder is created.

  • At most 4 open tasks per side at a time.

Good to know

  • Keep the Antigravity app open: only then do tasks show up in it. With the app closed, new tasks run with the agy CLI in the background (not shown in the app), and conversations that live in the app can only be continued once it is open again. duet status shows whether the app is running.

  • Stopped in the app: if someone presses stop in the Antigravity app, the sending agent is told the conversation was stopped there, instead of getting an unexplained failure; task_followup lets it carry on in the same conversation.

  • Where read-only ends in Antigravity: the app can stop commands, but not direct file edits in the project folder. So before a read-only task duet records the project's state, and if files changed by the end, the result says so plainly, with the diff and a git apply -R command that undoes exactly those changes (the project must be a git repository).

  • Antigravity conversations in the app can see duet's tools: the app shares one duet server across all its conversations. If a conversation duet started calls a duet tool, the call is declined and the conversation is told to finish the work itself.

  • What the round limit covers: it stops an agent that keeps following up. At the limit the agent should stop and ask you; if it insisted on starting a new task to get around it, duet could not stop that (its rules forbid it). How long a single task runs, and how many tokens it uses, is up to Codex / Antigravity.

  • Forcing one way of running: DUET_AG_BACKEND=cli makes Antigravity tasks always use the agy CLI; DUET_CODEX_BACKEND=exec makes Codex tasks use codex exec (they then do not show up in the Codex app). With a Codex CLI too old to have app-server, duet switches to codex exec on its own.

  • Undoing an apply: the result of task_apply includes a git apply -R <patch> command that undoes exactly the changes it brought in.

  • Codex versions and models: which models you can use depends on the Codex client version; new models (such as gpt-6.2-*) need a new version. duet picks the newest among the terminal's codex, the one inside Codex.app, and the one inside ChatGPT.app (which the desktop Codex uses). If the terminal's codex is old, codex update upgrades it. A model the current version cannot use is refused at handoff, with the usable ones listed; if no model was given and the configured default is unusable, a usable one is picked. To pin a codex, set DUET_CODEX_BIN.

  • "Codex would like to access Documents": macOS shows this when Codex reads its own config (which lists projects under ~/Documents); duet does not read that folder.

Files

Path

Contents

~/.duet/hub.db

Tasks, mailbox, and your choices (both sides' models, the round limit)

~/.duet/jobs/<task_id>/

Each task's event log and the diff of its changes; isolated tasks' git worktrees live here too

~/.duet/*-models.json

Cached model lists for both sides

~/.duet/state.json

What duet installed / synced (uninstall relies on it)

~/.duet/backups/

Backups taken before each change to config.toml

Similar projects

Project

How it differs from duet

zbush/antigravity-codex-plugin

Also two-way, through the official CLIs; no isolated review loop, mailbox, config sync or model compatibility handling

crazyzhang277/codex-antigravity-bridge

Codex → Antigravity only, focused on parallel implementation in separate git worktrees

aa-blinov/agent-orchestrator

Supports more agents (Claude Code, OpenCode), with synchronous calls

mcp_agent_mail

A full-featured mailbox for many agents

rulesync

Syncs rules / MCP / skills across a dozen tools

Tests

npm test

Tests use a temporary HOME, a fake codex (with app-server), a fake agy and a fake Antigravity app server; your real config is never touched.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers