Skip to content
HomeNewsConceptsGuidesToolbox
AboutSubscribeUA
Subscribe

AI Today Brief

The daily AI-engineering brief. Built in public. EN · UA.

XTelegramLinkedInYouTubeRSS

Follow AI Today Brief on LinkedIn for daily AI-engineering updates and the weekly “5 shifts that changed how developers work” PDF.

Explore

NewsDigestsConceptsGuides

Company

SubscribeAdvertiseAbout

Legal

Editorial policyAI disclosurePrivacyTerms

© 2026 AI Today Brief. All rights reserved.

  1. Home/
  2. News/
  3. Token & cost optimization/
  4. Inspecting Codex Request Payloads Reveals 9,400 Token Overhead per Prompt
Token & cost optimization

Inspecting Codex Request Payloads Reveals 9,400 Token Overhead per Prompt

August 5, 2026· 6 min read
OKCurated by Oleksandr Kuzmenko, AI Product Engineer·Updated August 5, 2026·Sources cited on every story
AI-assisted · editor-reviewed·How we use AI
Inspecting Codex Request Payloads Reveals 9,400 Token Overhead per Prompt

A deep-dive investigation into Codex CLI 0.145.0 request payloads shows that a simple 16-character prompt generates a 43 KB HTTP JSON request. Bundled instructions, environment context, and tool definitions consume over 9,400 input tokens before any user code executes.

Why it matters

Understanding payload overhead is critical for developers managing token costs, context window limits, and latency when building or using CLI-based AI agents.

TL;DR

  • 01Codex CLI adds ~9,400 tokens of system framing, tool definitions, and metadata to initial prompts.
  • 02AGENTS.md files are merged hierarchically from repo root to the execution working directory.
  • 03Large command outputs are truncated but still increase payload size significantly before triggering history compaction.

Payload Decomposition and Initial Baseline

Capturing raw JSON HTTP requests from Codex CLI 0.145.0 reveals significant prompt wrapping. A basic 16-character user input (Reply with pong.) produces a raw request body of 42,980 bytes. When encoded using o200k_base, the payload estimates at approximately 9,435 tokens. The wrapped prompt accounts for roughly 25 tokens (~0.3% of the request payload), while system framing, permissions, context metadata, and bundled tools make up the remaining 99.7%.

Instruction Chaining across AGENTS.md Files

Codex builds instruction chains by scanning upward from the working directory to the repository root:

  • Starting in a child directory automatically aggregates AGENTS.md from the root down to that child folder.
  • Executing file listing commands like ls child from the root does not trigger automatic loading of child/AGENTS.md into the instruction chain.
  • Synthetic markers demonstrate that instruction text is passed verbatim in subsequent requests, directly impacting the prompt baseline.

Output Truncation and History Compaction

Command execution output is appended directly into execution history. While a 10,000-line log is pruned to head-and-tail samples, payload size still spikes from ~9,584 tokens to 25,835 tokens. Compaction triggers when approaching configured limits (e.g., a 12,000 token threshold), executing a dedicated summary request (68,375 bytes / ~21,408 tokens) before rebuilding conversation history around retained messages.

#Codex CLI#o200k_base
ShareShare on XShare on LinkedIn
← Previous storyLLM Anthropic Plugin Adds Claude 5 Support and Server-Side Model Context Protocol Tools

Related stories

  • Token & cost optimizationOptimizing Claude Token Consumption to Prevent Hitting Anthropic 90% Rate Limits
  • Token & cost optimizationContext Preservation Techniques to Prevent Token Burn in Claude Workflows
  • Token & cost optimizationGPU Management: Why Idle Hardware is the Next Enterprise Bottleneck
  • Token & cost optimizationLiquid AI Releases LFM2.5 Encoders for Fast 8K Context CPU Inference

Email digest

Get the morning AI brief

One email a day — the stories that matter for engineers, founders and tech leads. Human-edited, with links to primary sources.

  • ✓120+ sources scanned daily
  • ✓Edited by a human
  • ✓1 email per day
  • ✓EN + UA

By subscribing you agree to the privacy policy.