bug: quiet mode cannot output raw text -- can only output json

Resolved 💬 1 comment Opened Apr 23, 2025 by moppywhip Closed Apr 24, 2025

What version of Codex is running?

0.1.4161006

Which model were you using?

o4-mini

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

Run

codex -q "explain this codebase to me"

What is the expected behavior?

Codex will print out the final output of the assistant after completing the task in raw text format.

What do you see instead?

Codex prints out JSON version of output:

{
  "id": "msg_6809663857f8819297b496571e4333f70d4dddf309672b1e",
  "type": "message",
  "status": "completed",
  "content": [
    {
      "type": "output_text",
      "annotations": [],
      "text": "Here’s a high-level tour of the Codex codebase—what it is, how it’s organized, and the major pieces you’ll encounter:  \n\n1. What is this project?  \n   • An interactive, terminal-based AI assistant (“codex”) built on top of OpenAI’s APIs.  \n   • Lets you chat with the model, generate or patch code, run shell commands in a sandbox, review diffs, manage approvals, etc.  \n   • Written in TypeScript + React (Ink) and packaged as an npm-CLI (`codex`).  \n\n2. Top-level layout  \n   • bin/ – the `codex` stub that invokes `dist/cli.js`.  \n   • src/ – all of the TS/TSX source:  \n      – cli.tsx & cli-singlepass.tsx: entry-points for the multi-pass and “single-pass” modes.  \n      – app.tsx: the root Ink `<App>` component rendering overlays, chat panels, diff views, etc.  \n      – components/: reusable Ink/React UI (chat, overlays, typeahead, diff, history).  \n      – utils/: core logic and helpers (config, logging, model-API wrappers, token estimation, file system suggestions, git integration, parsing & applying patches, sandboxed exec, session storage, etc.).  \n      – utils/agent/: the “agent loop” machinery for streaming LLM responses, interpreting functions/patches, executing commands, and review/approval flows.  \n      – parse-apply-patch.ts: turning unified-diff outputs into real file edits.  \n   • examples/: several end-to-end demos (e.g. “impossible-pong”, “prompt-analyzer”) showing how to script tasks with a `task.yaml` harness.  \n   • tests/: ~200 Vitest suites covering everything from low-level utilities (text-buffer, patch parsing) to UI components and full agent behaviors.  \n\n3. Core concepts & flows  \n   • Configuration & environment: `.env` or env vars for your OpenAI API key, plus optional config (~`~/.codexrc`).  \n   • Session & history: in‐memory and on-disk storage of prompt/response histories under src/utils/session.ts + storage/.  \n   • UI: Ink lets us build React-style terminal screens; overlays (help, onboarding, model selector), a scrolling chat window, diffs, typeahead, etc.  \n   • LLM interactions: src/utils/model-utils.ts + openai client to send chat or function-call requests, stream tokens, handle rate limits/retries.  \n   • Agent loop:  \n      1. Gather context (files, git diff, past chat), send LLM request.  \n      2. Stream & render response; if the model emits a “patch” or function call, parse it.  \n      3. Show diff overlay and ask for approval (auto-approve mode optional).  \n      4. If approved, apply patch to files (using parse-apply-patch + git staging).  \n      5. Possibly exec shell commands in a sandbox (src/utils/agent/sandbox) and feed that back into the loop.  \n      6. Repeat until done or interrupted.  \n   • Single-pass mode: a simpler one-shot ask-and-apply model, useful for scripting.  \n\n4. Build & distribution  \n   • build.mjs (esbuild) bundles TS into a single ESM cli.js under dist/.  \n   • bin/codex.js is the small shim that locates `dist/cli.js` and runs it with Node.  \n   • Pre-commit + ESLint/Prettier for style, Vitest for testing.  \n\n5. Getting started  \n   • Install via npm/yarn or run locally:  \n       · `pnpm install` (or `npm install`)  \n       · `OPENAI_API_KEY=… codex`  \n   • Or try the examples under examples/ by running their `run.sh` scripts.  \n\nAt its heart, Codex is an LLM-driven REPL for code & shell. The TS code is neatly split into a UI layer (Ink components) and an agent layer (prompting, parsing, patch application, sandboxed execution), with a ton of glue and safety checks in utils. Let me know if you’d like to dive deeper into any particular directory or flow!"
    }
  ],
  "role": "assistant"
}

Additional information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗