You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
app-serverIssues involving app server protocol or interfacescontextIssues related to context management (including compaction)enhancementNew feature or request
Please expose current context window usage through the Codex SDK / JSON event stream, similar to the Context XX% used indicator shown in the Codex CLI.
Today, @openai/[email protected] exposes per-turn token usage on turn.completed:
input_tokens
cached_input_tokens
output_tokens
But it does not appear to expose the current thread context usage percentage, total context tokens, or effective/max context window size.
Why is this useful?
Applications embedding Codex SDK can show users the same operational signal available in the CLI, for example:
Context 37.2% used (74,480 / 200,000 tokens)
This is useful for long-lived agent sessions, chat bots, and UI integrations that need to warn users before context gets too full or suggest compaction.
Claude Agent SDK exposes a dedicated get_context_usage() API returning percentage, totalTokens, maxTokens, category breakdowns, etc. A similar SDK-level capability in Codex would let integrations keep parity with the CLI without estimating from per-turn token usage.
The SDK is intended for basic automations. If you need more sophisticated metrics than are provided by codex exec (which is used by the SDK), you can use the app server interface.
Is this OpenAI's official stance, and is that documented clearly-enough if that's the case? I was under other assumptions while building https://agor.live/ on top of the SDK. Typically the name "software developer kit" means more than basic automations. The general assumption is that it's to build great integrations like we're providing with Agor.
I'd argue that being context-aware after each turn is probably in-scope even for basic automation. The host app calling the SDK can benefit from context window metadata. The fact it's shown constantly in the CLI speaks for how core it is to its operation.
app-serverIssues involving app server protocol or interfacescontextIssues related to context management (including compaction)enhancementNew feature or request
Activity
etraut-openai commentedon May 6, 2026
The SDK is intended for basic automations. If you need more sophisticated metrics than are provided by
codex exec(which is used by the SDK), you can use the app server interface.mistercrunch commentedon May 25, 2026
Is this OpenAI's official stance, and is that documented clearly-enough if that's the case? I was under other assumptions while building https://agor.live/ on top of the SDK. Typically the name "software developer kit" means more than basic automations. The general assumption is that it's to build great integrations like we're providing with Agor.
I'd argue that being context-aware after each turn is probably in-scope even for basic automation. The host app calling the SDK can benefit from context window metadata. The fact it's shown constantly in the CLI speaks for how core it is to its operation.
fix(codex): use last_token_usage for context window (not lifetime cum…
fix(codex): correct context-window accounting (use last_token_usage) …