Reverse-Engineering Codex's System Prompts with mitmproxy
Agent tools like Codex are black boxes whose behavior is dictated by hidden system prompts. Intercepting those prompts gives developers a concrete baseline to study, critique, or replicate the prompt engineering that drives an agent's output quality.
Codex is an agent that relies entirely on the quality of its system prompts to direct a large model. Capturing its traffic with mitmproxy exposes those prompts in full detail. The setup routes Codex through a local reverse proxy pointed at DeepSeek's API, then inspects every request and response in a browser-based dashboard.
The process uses CC Switch to redirect Codex from OpenAI to a domestic model, then mitmweb in reverse-proxy mode to intercept the chat completion calls. The captured payloads show the system prompt, the user message, and the model's reply side by side. After inspection, restoring the original base_url in Codex's config.toml returns everything to normal.
System prompts are the entire differentiator for an agent like Codex; the model underneath is interchangeable, which is why the proxy swap to DeepSeek works at all.
Using a domestic model through CC Switch is not just a cost play — it also makes traffic inspection easier when the API format matches OpenAI's.
The mitmweb dashboard turns a normally opaque agent interaction into a transparent three-part view: system prompt, user input, model output.