Codex: Codex Workflow Modes

Last updated: 2026-08-31

Codex supports multiple workflow modes. Choose the right one based on task complexity and desired autonomy level.

📋 Prerequisites: Understanding Codex basic operations

1. What You Will Learn


2. Three Workflow Modes

Mode Autonomy Level Human Involvement Best For
Question Mode Low High Consulting, analysis, learning
Task Mode Medium Medium Specific development tasks
Agent Mode High Low Complex multi-step tasks

3. Question Mode

(1) Characteristics

(2) Usage

TEXT 📖 Display only
> Explain React useEffect's cleanup mechanism
> What does this regex match? /\d{3}-\d{4}/
> What's the difference between type and interface in TypeScript?
> How to implement graceful shutdown in Node.js?

▶ Example 1: Alice Uses Question Mode to Learn

TEXT 📖 Display only
# Alice takes over a Rust project, uses Question Mode to quickly understand

> Explain the AST structure in src/parser/mod.rs
> What error handling pattern does this project use?
> Why is Arc<Mutex<T>> used here instead of RefCell<T>?
> Draw me a module dependency diagram

4. Task Mode

(1) Characteristics

(2) Usage

TEXT 📖 Display only
> Add JWT support to the auth module
> Fix the failing test_user_login test
> Convert this.state to React Hooks
> Add rate limiting to the API

(3) Task Decomposition Principles

Principle Description
Single Responsibility One task at a time
Clear Boundaries Specify modification scope
Include Verification Specify how to verify completion
Reference Existing Specify style references

▶ Example 2: Bob's Task Decomposition

TEXT 📖 Display only
# Bob needs to add user registration, decomposed into:

Step 1: "Create User model with email, password_hash, created_at fields"
Step 2: "Implement registration API endpoint POST /api/register with email format validation"
Step 3: "Add password hashing using bcrypt"
Step 4: "Write integration tests for the registration flow"
Step 5: "Add email verification flow"

5. Agent Mode

(1) Characteristics

(2) Usage

BASH
# Full Auto mode
codex --full-auto "Migrate the entire project from JavaScript to TypeScript"

# Or switch during conversation
/mode full-auto

(3) Agent Work Loop

100%
graph TB
    A[Receive Task] --> B[Analyze & Understand]
    B --> C[Plan Steps]
    C --> D[Execute Step 1]
    D --> E[Verify Result]
    E --> F{Success?}
    F -->|No| G[Fix & Retry]
    G --> D
    F -->|Yes| H[Execute Step 2]
    H --> I[Continue...]
    I --> J[Aggregate Results]
    J --> K[Report Complete]

▶ Example 3: Alice's Agent Mode

TEXT 📖 Display only
# Alice uses Agent Mode for a large refactoring
> Migrate the Express project to Fastify:
> 1. Replace all route definitions
> 2. Update middleware syntax
> 3. Modify startup scripts
> 4. Ensure all tests pass
> 5. Update package.json

# Codex executes autonomously:
→ Scanning 45 files...
→ Converting routes (32 routes)...
→ Updating middleware (8 files)...
→ Test run: 89/89 passed ✓
→ Updating dependencies...
→ Final test: 89/89 passed ✓
→ Migration complete!

6. Mode Selection Strategy

(1) Decision Tree

TEXT 📖 Display only
Task type?
├── Only need information → Question Mode
├── Need to modify code
│   ├── Single clear task → Task Mode
│   └── Complex multi-step task
│       ├── Controllable risk → Agent Mode
│       └── High risk → Task Mode (step-by-step)

(2) Selection Matrix

Task Mode Reason
Explain code logic Question No modification needed
Fix a single Bug Task Single and clear
Add a feature Task Needs step-by-step confirmation
Full project refactoring Agent Many steps but pattern-based
Database migration Task High risk, needs step-by-step confirmation
Batch generate tests Agent Repetitive work

7. Hybrid Workflows

In practice, the three modes are often combined:

TEXT 📖 Display only
# Alice's hybrid workflow

1. [Question] "What's the auth architecture of this project?"
2. [Question] "What are the best practices for JWT refresh tokens?"
3. [Task] "Add a JWT refresh token endpoint"
4. [Task] "Write unit tests for refresh tokens"
5. [Agent] "Review the entire auth module, fix all security issues"

❓ FAQ

Q Can I switch modes within one session?
A Yes. Use /mode command or adjust your interaction style — question-style is Question Mode, task-style is Task Mode.
Q Is Agent Mode safe?
A Depends on task risk and approval policy. Pair with Git safety net — commit before operations, rollback on errors. High-risk tasks should use Task Mode.
Q How do I judge if a task is suited for Agent Mode?
A Ask yourself three questions: 1) Are the steps predictable? 2) Are errors reversible? 3) Does it require human judgment? All yes → Agent; otherwise → Task Mode.
Q Does Question Mode consume context?
A Yes. Each question and answer uses context window space. After extensive questioning, use /compact or /new.
Q Which mode saves the most tokens?
A Question Mode is most economical — only outputs text, no operations. Agent Mode is most expensive — requires multiple rounds of execution and verification.

📖 Summary


📝 Exercises

  1. Basic (⭐): Complete different tasks on the same topic using all three modes, record experience differences.
  2. Intermediate (⭐⭐): Use Task Mode to complete a medium-complexity feature, practice task decomposition.
  3. Advanced (⭐⭐⭐): Design a hybrid workflow — Question Mode for analysis, Task Mode for implementation, Agent Mode for review.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏