The run_main function is the primary entrypoint for starting a Codex ACP agent. It initializes the tracing subscriber (logging to stderr), parses configuration overrides, loads the global Config, and sets up the residency requirement for the HTTP client. The agent communicates via stdio, bridging the Agent Client Protocol (ACP) with the codex-rs infrastructure.
To use this function, you must provide an optional path to the codex_linux_sandbox_exe and a CliConfigOverrides object. The agent then serves the protocol using the provided stdin and stdout streams.
use codex_acp::run_main;
use codex_utils_cli::CliConfigOverrides;
use std::path::PathBuf;
#[tokio::main]
async fn main() -> std::io::Result<()> {
let sandbox_exe = Some(PathBuf::from("/path/to/sandbox"));
let cli_overrides = CliConfigOverrides::default(); // Or parsed from CLI
run_main(sandbox_exe, cli_overrides).await
}