Skip to content

context-weight — OpenAI Codex CLI

Analyze how Codex context grows, what resident instructions cost, and where fidelity stops. Use for context-window pressure, growth curves, loaded-surface audits, or compaction questions.

In practice

What it does

Shows how a Codex session's context grew and roughly what kind of record filled it — but draws a hard line at what rollout logs can prove: they carry token counts and record types, never which specific prompt, instruction, or tool actually filled the window, and this skill refuses to guess rather than approximate one.

When to reach for it

  • Wondering why a session's context ballooned, at the level rollout logs can actually answer.
  • Auditing resident config surfaces in a repo against a token budget.
  • Comparing sessions to see whether growth looks routine or unusual for this kind of work.
  • Not for live pruning guidance or a GUARDRAILS.md residency check — watch is Claude-only outright, and constraints --harness codex can only return the honest fidelity-limit line instead.

Worked example

python3 bin/context_weight.py session --harness codex --codex-home <codex-home>
python3 bin/context_weight.py overview --harness codex --codex-home <codex-home>
python3 bin/context_weight.py audit --project <repo>

session and overview report token-count growth curves and record-type byte shares — never turn a byte share into a claim about which prompt or tool filled the window. audit checks resident config surfaces against a budget, in tokens only.

Failure modes & fallbacks

  • constraints --harness codex. It can only return the engine's fidelity-limit line — Codex cannot answer live pruning or whether a kit's GUARDRAILS.md is still resident; cross-link the Claude page for that story instead of implying Codex has it.
  • A byte share gets read as content attribution. It never is one — say what kind of record filled the window, never which instruction or tool did.
  • The plugin root can't be proven. Stop and point at doctor rather than guessing a path.

Cost & safety

Every command here is read-only measurement over local rollout logs — nothing dispatched, nothing written. The audit is about resident tokens, never dollars, and every estimated figure carries its label; no context estimate here is a billing statement.

  • Deep dive: context weight — the fuller fidelity story and what the Claude harness can additionally support.
  • usage — real historical Codex activity, versus this page's token-weight estimate.
  • doctor — the root-resolution check every Codex skill depends on.

The skill card — what the model reads

This is the SKILL.md body the model reads, transformed for this page: the source's own leading title, if it had one, is removed; every remaining heading is demoted one level to nest under this section; and relative links are rewritten to site or GitHub URLs. ${CLAUDE_PLUGIN_ROOT} and {{POLYTROPOS_ROOT}} are install-time path variables, left intact exactly as the model sees them. The unmodified original is codex/skills/context-weight/SKILL.md.

Resolve the plugin root before running commands

Set POLYTROPOS_ROOT from this file's real location: in plugin mode, this file is <root>/codex/skills/context-weight/SKILL.md, so ascend to <root>; in a managed copied install, use the installer-resolved POLYTROPOS_ROOT="{{POLYTROPOS_ROOT}}". Reject a literal placeholder. Before shelling out, verify $POLYTROPOS_ROOT/data/pricing.codex.json and $POLYTROPOS_ROOT/bin/context_weight.py exist. If proof fails, stop and direct the user to python3 bin/harness_select.py doctor --harness codex; never run a guessed or stale path.

Use only the engine's real Codex surfaces:

python3 "$POLYTROPOS_ROOT/bin/context_weight.py" session --harness codex --codex-home <codex-home>
python3 "$POLYTROPOS_ROOT/bin/context_weight.py" overview --harness codex --codex-home <codex-home>
python3 "$POLYTROPOS_ROOT/bin/context_weight.py" audit --project <repo>
python3 "$POLYTROPOS_ROOT/bin/context_weight.py" demo

Codex rollout logs provide token-count growth curves and record-type byte shares, not content provenance. Never turn those byte shares into claims about which prompt, instruction, or tool filled the window. watch is Claude-only, and constraints --harness codex can only return the engine's explicit fidelity-limit line; Codex cannot answer live pruning or GUARDRAILS.md residency.

Relay the engine's estimated-token and unpriced labels. The audit is about resident tokens, never dollars, and no context estimate is a billing statement.