Most of this repository code is implemented and reviewed by
codexagents.
An Agent Client Protocol (ACP)–compatible agent that bridges the OpenAI Codex runtime with ACP clients over stdio. This project is under active development — features are evolving and breaking changes are likely.
- Agent Client Protocol (ACP) over stdio using
agent-client-protocol. - Integrates with the Codex Rust workspace for conversation management and event streaming.
- Slash commands with ACP AvailableCommands updates (advertised to clients on session start).
- Status output tailored for IDEs (workspace, account, model, token usage).
- Supports ACP session modes:
read-only,auto(default), andfull-access. - Automatically launches an internal MCP filesystem server (
acp_fs) built withrmcp, so Codex reads/writes files through ACP tooling instead of shell commands.
-
ACP Agent implementation
- Handles
initialize,authenticate,session/new,session/prompt,session/cancel. - Authentication support for OpenAI (ChatGPT/API key) and custom model providers.
- Streams Codex events (assistant text and deltas, reasoning deltas, token counts) as
session/updatenotifications.
- Handles
-
Slash commands (advertised via
AvailableCommandsUpdate)- Implemented:
/init— Create anAGENTS.mdwith repository contributor guidance. Uses a bundled prompt (src/agent/prompt_init_command.md)./status— Rich status (workspace, account, model, token usage)./compact— Request Codex to compact/summarize the conversation to reduce context size./review— Ask Codex to review current changes, highlight issues, and suggest fixes.
- Implemented:
-
Session modes
- Advertises
read-only,auto(current), andfull-accesson new session. - Clients may switch modes via ACP
session/setMode; the agent emitsCurrentModeUpdate.
- Advertises
-
Custom model provider support
- Dynamic model listing and switching for custom (non-OpenAI) providers.
- Model format:
{provider_id}@{model_name}(e.g.,anthropic@claude-3-opus). - Configure providers and models via Codex config profiles.
- Dedicated
custom_providerauthentication method for non-builtin providers.
- Rust (Rust 2024 edition; rustc 1.90+ as pinned in
rust-toolchain.toml). - Network access for building Git dependencies (Codex workspace, ACP crate).
make buildTip: use
make release(orcargo build --release) when shipping the binary to an IDE like Zed. The release build lives attarget/release/codex-acp.
Configuration in Zed
Add this configuration to zed settings.
"agent_servers": {
"Codex": {
"command": "/path/to/codex-acp",
"args": [],
"env": {
"RUST_LOG": "info"
}
}
}When a session starts, codex-acp spins up an in-process TCP bridge and registers an MCP server named acp_fs using rmcp. Codex then calls structured tools:
read_text_file— reads workspace files via ACPclient.read_text_file, falling back to local disk if the client lacks FS support.write_text_file— writes workspace files via ACPclient.write_text_file, with a local fallback.edit_text_file— apply a focused replace in a file and persist.multi_edit_text_file— apply multiple sequential replacements and persist.
codex-acp also injects a default instruction reminding the model to use these tools rather than shelling out with cat/tee. If your client exposes filesystem capabilities, file access stays within ACP.
Note: The acp_fs tools are dynamically enabled or disabled based on the client's filesystem capabilities. If the client does not support reading files, read_text_file is hidden. If the client does not support writing files, write_text_file, edit_text_file, and multi_edit_text_file are hidden.
The /status command prints a human-friendly summary, e.g.:
📂 Workspace
• Path: ~/path/to/workspace
• Approval Mode: on-request
• Sandbox: workspace-write
👤 Account
• Signed in with ChatGPT (or API key / Not signed in)
• Login: user@example.com
• Plan: Plus
🧠 Model
• Name: gpt-5
• Provider: OpenAI
• Reasoning Effort: Medium
• Reasoning Summaries: Auto
📊 Token Usage
• Session ID: <uuid>
• Input: 0
• Output: 0
• Total: 0
Notes
- Some fields may be unknown depending on your auth mode and environment.
- Token counts are aggregated from Codex
EventMsg::TokenCountwhen available.
codex-acp supports multiple authentication methods:
- ChatGPT: Sign in with your ChatGPT account via
codex login - API Key: Use
OPENAI_API_KEYfrom environment orauth.json
For custom model providers (e.g., Anthropic, custom LLMs):
-
Configure the provider in your Codex config:
model_provider_id = "anthropic" model = "claude-3-opus" [model_providers.anthropic] name = "Anthropic" # ... provider-specific configuration [profiles.custom-fast] model = "claude-3-haiku" model_provider = "anthropic"
-
The agent will advertise a
custom_providerauthentication method during initialization. -
Authenticate with provider-specific credentials configured in your Codex setup.
- OpenAI: Standard authentication, no model switching (uses config defaults)
- Custom Providers:
- Model listing via
available_modelsin session responses - Model switching via
session/setModelwith{provider}@{model}format - Multiple model profiles for easy switching
- Model listing via
Example model switching (custom providers only):
{
"method": "session/setModel",
"params": {
"session_id": "...",
"model_id": "anthropic@claude-3-haiku"
}
}codex-acp uses tracing + tracing-subscriber and can log to stderr and/or a file. Configure it via environment variables:
Environment variables (highest precedence first):
CODEX_LOG_FILE— Path to append logs (non-rotating). Parent directories are created automatically. ANSI is disabled for file logs.CODEX_LOG_DIR— Directory for daily-rotated logs (file name:acp.log). Directory is created automatically. ANSI is disabled for file logs.CODEX_LOG_STDERR— Set to0,false,off, ornoto disable stderr logging. Enabled by default.RUST_LOG— Standard filtering directives (defaults toinfoif unset/invalid). Examples:info,debug,codex_acp=trace,rmcp=info.
Behavior:
- If
CODEX_LOG_FILEis set, logs go to stderr (unless disabled) and the specified file. - Else if
CODEX_LOG_DIRis set, logs go to stderr (unless disabled) and a daily-rotated file in that directory. - Else logs go to stderr only (unless disabled).
Examples:
# Console only
RUST_LOG=info cargo run --quiet
# Console + append to file (non-rotating)
RUST_LOG=debug CODEX_LOG_FILE=./logs/codex-acp.log cargo run --quiet
# Console + daily rotation under logs directory
RUST_LOG=info CODEX_LOG_DIR=./logs cargo run --quiet
# File only (disable stderr)
CODEX_LOG_STDERR=0 CODEX_LOG_FILE=./logs/codex-acp.log cargo run --quiet
# MCP filesystem server also honors logging env:
RUST_LOG=debug CODEX_LOG_DIR=./logs cargo run --quiet -- --acp-fs-mcp- Branching: prefer topic branches; small, focused commits.
- Lint/test locally using
cargo check,cargo fmt,cargo clippy, andcargo test. - Logging: see the Logging section above for configuration. Typical dev setup:
RUST_LOG=info.
- Zed ACP example (Claude): https://github.com/zed-industries/claude-code-acp
- Agent Client Protocol (Rust): https://crates.io/crates/agent-client-protocol
- OpenAI Codex (Rust workspace): https://github.com/openai/codex