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
{{ message }}
Repository navigation
Automatic context compaction in Codex Desktop is extremely slow, sometimes taking around a full minute #24372
macOS 26.5 on a MacBook Pro 16-inch with Apple M5 Max and 128 GB memory.
What issue are you seeing?
Over the last two days, automatic context compaction in Codex Desktop has become extremely slow.
In the representative session I uploaded, Codex reached the automatic compaction step and paused at Context automatically compacted / Automatically compacting context. The longest observed compaction took around a full minute before the agent continued.
This is clearly abnormal compared with normal task flow. Every long-running task can now spend a significant amount of time blocked on context compaction, which makes Codex feel much slower even when the actual coding/editing work is otherwise progressing.
This report is specifically about automatic context compaction latency. The compaction eventually completes in the representative case, but the delay is long enough to disrupt the workflow.
What steps can reproduce the bug?
Open Codex Desktop on macOS.
Work in a long-running coding session until automatic context compaction is triggered.
Observe that Codex pauses at the context compaction step.
In recent sessions, this pause can last close to a full minute before the agent continues.
changed the title [-]Slow automatic context compaction in Codex Desktop[/-][+]Automatic context compaction in Codex Desktop is extremely slow, sometimes taking around a full minute[/+]on May 24, 2026
Solution: Fix Extremely Slow Context Compaction in Codex Desktop
Issue:#24372 — Automatic context compaction in Codex Desktop is extremely slow, sometimes taking around a full minute.
Related Issues:
#24332 — Allow compaction-specific reasoning effort and service tier (enhancement proposal with prepared implementation)
#23998 — Codex app is much slower after latest update (duplicate)
1. Root Cause Analysis
1.1 Primary Root Cause: Compaction Inherits Full Reasoning Effort and Service Tier
The core issue is that context compaction reuses the same reasoning_effort and service_tier settings as normal conversation turns. This means:
High reasoning effort on compaction: When a user has model_reasoning_effort = "high" configured for normal turns, compaction also uses "high" reasoning effort. Compaction is a summarization task that does not benefit from deep reasoning — it should use minimal or no reasoning effort.
Same service tier for compaction: When a user has service_tier = "default" or "priority", compaction requests also use that tier. Compaction is a batch-like operation that does not need priority routing, and using the fast tier would significantly reduce latency.
turn_context.reasoning_effort,// ← Inherited from session config
turn_context.reasoning_summary,
turn_context.config.service_tier.clone(),// ← Inherited from session config
1.3 Why This Causes ~1 Minute Delays
High reasoning effort triggers extended thinking chains, which can add 30-60+ seconds to any request.
Default/priority service tier may route to heavily loaded capacity, whereas the fast tier uses dedicated lower-latency infrastructure.
Compaction is called multiple times during long-running sessions, so each ~60s compaction adds up to significant total delay.
The compaction task blocks the entire session — no coding work can proceed while compaction is in progress.
1.4 Secondary Contributing Factors
No streaming progress feedback: During compaction, the UI shows "Context automatically compacted" with no progress indicator, making the delay feel longer.
Retry overhead: The retry logic in compact_remote_v2.rs (up to 2 retries with exponential backoff) can add additional delay when requests fail.
Large context window: When compaction is triggered, the entire conversation history (potentially 100K+ tokens) must be sent to the model, increasing processing time.
Add two new optional configuration fields to ConfigToml that allow users to override reasoning effort and service tier specifically for compaction:
compact_model_reasoning_effort — Reasoning effort for compaction (defaults to "low")
compact_service_tier — Service tier for compaction (defaults to "fast")
Phase 2: Wire Configuration Through to Compaction Code
Modify the three compaction implementations to use the new compact-specific settings when available.
Phase 3: Sensible Defaults
Default compaction to use reasoning_effort = "low" and service_tier = "fast" when the user has not explicitly configured compact-specific settings. This provides immediate improvement for all users.
// Add to ConfigToml struct alongside existing model_reasoning_effort and service_tier fields:/// Reasoning effort to use for context compaction./// When unset, compaction defaults to "low" reasoning effort regardless of/// the session-level model_reasoning_effort setting.pub compact_model_reasoning_effort:Option<ReasoningEffort>,/// Service tier to use for context compaction.
/// When unset, compaction defaults to "fast" service tier regardless of
/// the session-level service_tier setting.
pub compact_service_tier:Option<String>,
implConfig{/// Returns the reasoning effort to use for compaction./// Defaults to "low" if not explicitly configured.pubfncompact_reasoning_effort(&self) -> Option<ReasoningEffortConfig>{// If compact-specific effort is set, use itifletSome(effort) = self.compact_model_reasoning_effort{returnSome(effort.into());}// Default compaction to low reasoning effortSome(ReasoningEffortConfig::Low)}/// Returns the service tier to use for compaction./// Defaults to "fast" if not explicitly configured.pubfncompact_service_tier(&self) -> Option<String>{// If compact-specific tier is set, use itifletSome(tier) = &self.compact_service_tier{returnSome(normalize_service_tier(tier));}// Default compaction to fast tierSome("fast".to_string())}}
3.3 Update Local Compaction (codex-rs/core/src/compact.rs)
In drain_to_completed, replace the inherited settings with compact-specific ones:
let result = match client_session
.stream(
prompt,&turn_context.model_info,&turn_context.session_telemetry,
turn_context.config.compact_reasoning_effort(),// ← Use compact-specific
turn_context.reasoning_summary,
turn_context.config.compact_service_tier(),// ← Use compact-specific
turn_metadata_header,&InferenceTraceContext::disabled(),).await
#[test]fnconfig_toml_compact_reasoning_effort_deserializes(){let config:ConfigToml = toml::from_str(r#"compact_model_reasoning_effort = "high""#).expect("compact_model_reasoning_effort should deserialize");assert_eq!(config.compact_model_reasoning_effort,Some(ReasoningEffort::High));}#[test]fnconfig_toml_compact_service_tier_deserializes(){let config:ConfigToml = toml::from_str(r#"compact_service_tier = "fast""#).expect("compact_service_tier should deserialize");assert_eq!(config.compact_service_tier,Some("fast".to_string()));}
4.2 Integration Tests
Test remote compaction uses compact-specific settings:
#[tokio::test]asyncfnremote_manual_compact_uses_compact_specific_service_tier_and_reasoning_effort(){// Verify that when compact-specific settings are configured,// the remote compaction request uses those settings instead of// the session-level settings.}
4.3 Manual Testing
Baseline measurement: Run a long session with model_reasoning_effort = "high" and measure compaction latency.
After fix: Verify compaction completes in < 10 seconds with default compact settings.
Override test: Set compact_model_reasoning_effort = "high" and verify compaction uses high effort (backward compatibility).
4.4 Regression Tests
Ensure existing sessions without compact-specific config still work (backward compatibility).
Verify that API key auth mode still skips service tier for compaction (existing behavior).
Verify all three compaction paths (local, remote v1, remote v2) use the new settings.
5. Impact Assessment
5.1 Performance Impact
Scenario
Before Fix
After Fix
Improvement
High reasoning effort, default tier
~60s per compaction
~5-10s per compaction
6-12x faster
Standard reasoning effort, default tier
~15-30s per compaction
~5-10s per compaction
2-3x faster
User explicitly sets high compaction effort
~60s per compaction
~60s per compaction
No change (opt-in)
5.2 Cost Impact
Reduced cost: Using service_tier = "fast" and reasoning_effort = "low" for compaction reduces token consumption and compute cost per compaction event.
No impact on normal turns: Regular conversation turns continue to use user-configured settings.
5.3 Backward Compatibility
Fully backward compatible: The new config fields are optional. When unset, compaction defaults to low reasoning effort and fast service tier — a sensible improvement over the current behavior.
Users can opt out: Users who prefer the old behavior can set compact_model_reasoning_effort and compact_service_tier to match their session-level settings.
5.4 Risk Assessment
Risk
Likelihood
Mitigation
Compaction quality degrades with low reasoning
Low
Compaction is a summarization task; low reasoning is sufficient. Users can override.
Fast tier capacity limits
Low
Fast tier is designed for low-latency batch-like operations. Fallback to default tier if needed.
Config parsing errors
Very Low
New fields are optional with sensible defaults.
Breaking existing integrations
Very Low
Changes are additive only; no existing behavior is removed.
5.5 Files Modified
File
Change Type
Lines Affected
codex-rs/config/src/config_toml.rs
Add fields
+10
codex-rs/core/src/config/mod.rs
Add resolution methods
+20
codex-rs/core/src/compact.rs
Use compact settings
~3
codex-rs/core/src/compact_remote.rs
Use compact settings
~3
codex-rs/core/src/compact_remote_v2.rs
Use compact settings
~3
codex-rs/core/config.schema.json
Auto-regenerated
+20
codex-rs/core/src/config/config_tests.rs
Add tests
+50
codex-rs/core/tests/suite/compact_remote.rs
Add integration tests
+30
Total estimated impact: ~140 lines across 8 files.
6. Alternative Approaches Considered
6.1 Hardcode Low Effort + Fast Tier for All Compaction
Pros: Simplest implementation, immediate benefit for all users.
Cons: No user override capability; users who need high-quality compaction cannot opt in.
Verdict: Not recommended. The config-based approach (Phase 1) is better because it provides both automatic improvement and user control.
6.2 Auto-Detect Compaction Complexity
Pros: Dynamically adjusts reasoning effort based on context size.
Cons: Complex to implement correctly; heuristic-based; may produce inconsistent results.
Verdict: Over-engineering. The config-based approach is simpler and more predictable.
6.3 Streaming Progress Indicator for Compaction
Pros: Improves perceived latency.
Cons: Does not address the root cause (actual latency); only masks the problem.
Verdict: Complementary improvement, not a replacement for the primary fix.
7. Recommended Implementation Order
Step 1: Add compact_model_reasoning_effort and compact_service_tier to ConfigToml.
Step 2: Add resolution methods to Config with smart defaults (low effort, fast tier).
Step 3: Update compact.rs (local compaction) to use compact-specific settings.
Step 4: Update compact_remote.rs (remote compaction v1) to use compact-specific settings.
Step 5: Update compact_remote_v2.rs (remote compaction v2) to use compact-specific settings.
Step 6: Regenerate config schema with just write-config-schema.
Step 7: Add unit and integration tests.
Step 8: Run just fix -p codex-core and just test -p codex-core.
Thanks for reporting this problem. Until recently, Codex used a separate endpoint and server-side logic for compaction. We recently switched to a more robust approach where the compaction logic is moved locally using the same endpoint as normal turns. This eliminates "remote compaction" errors and increases the stability and reliability of compaction operations. If you see further problems with compaction, please use /feedback and open a new bug report.
Activity
github-actions commentedon May 24, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
[-]Slow automatic context compaction in Codex Desktop[/-][+]Automatic context compaction in Codex Desktop is extremely slow, sometimes taking around a full minute[/+]jshaofa-ui commentedon May 25, 2026
Solution: Fix Extremely Slow Context Compaction in Codex Desktop
Issue: #24372 — Automatic context compaction in Codex Desktop is extremely slow, sometimes taking around a full minute.
Related Issues:
1. Root Cause Analysis
1.1 Primary Root Cause: Compaction Inherits Full Reasoning Effort and Service Tier
The core issue is that context compaction reuses the same
reasoning_effortandservice_tiersettings as normal conversation turns. This means:High reasoning effort on compaction: When a user has
model_reasoning_effort = "high"configured for normal turns, compaction also uses"high"reasoning effort. Compaction is a summarization task that does not benefit from deep reasoning — it should use minimal or no reasoning effort.Same service tier for compaction: When a user has
service_tier = "default"or"priority", compaction requests also use that tier. Compaction is a batch-like operation that does not need priority routing, and using the fast tier would significantly reduce latency.1.2 Evidence from Source Code
compact.rs— Local/inline compaction (line ~544-546):compact_remote.rs— Remote compaction v1 (line ~195-201):compact_remote_v2.rs— Remote compaction v2 (line ~298-300):1.3 Why This Causes ~1 Minute Delays
fasttier uses dedicated lower-latency infrastructure.1.4 Secondary Contributing Factors
No streaming progress feedback: During compaction, the UI shows "Context automatically compacted" with no progress indicator, making the delay feel longer.
Retry overhead: The retry logic in
compact_remote_v2.rs(up to 2 retries with exponential backoff) can add additional delay when requests fail.Large context window: When compaction is triggered, the entire conversation history (potentially 100K+ tokens) must be sent to the model, increasing processing time.
2. Step-by-Step Fix Approach
Phase 1: Add Compaction-Specific Configuration Fields (Primary Fix)
Add two new optional configuration fields to
ConfigTomlthat allow users to override reasoning effort and service tier specifically for compaction:compact_model_reasoning_effort— Reasoning effort for compaction (defaults to"low")compact_service_tier— Service tier for compaction (defaults to"fast")Phase 2: Wire Configuration Through to Compaction Code
Modify the three compaction implementations to use the new compact-specific settings when available.
Phase 3: Sensible Defaults
Default compaction to use
reasoning_effort = "low"andservice_tier = "fast"when the user has not explicitly configured compact-specific settings. This provides immediate improvement for all users.3. Code Changes
3.1 Add Configuration Fields (
codex-rs/config/src/config_toml.rs)3.2 Add Config Resolution Methods (
codex-rs/core/src/config/mod.rs)3.3 Update Local Compaction (
codex-rs/core/src/compact.rs)In
drain_to_completed, replace the inherited settings with compact-specific ones:3.4 Update Remote Compaction v1 (
codex-rs/core/src/compact_remote.rs)3.5 Update Remote Compaction v2 (
codex-rs/core/src/compact_remote_v2.rs)In
run_remote_compaction_request_v2:3.6 Update Config Schema (
codex-rs/core/config.schema.json)Run
just write-config-schemaafter adding the new fields to regenerate the JSON schema.4. Testing Strategy
4.1 Unit Tests
Test compact-specific config resolution:
Test TOML deserialization:
4.2 Integration Tests
Test remote compaction uses compact-specific settings:
4.3 Manual Testing
model_reasoning_effort = "high"and measure compaction latency.compact_model_reasoning_effort = "high"and verify compaction uses high effort (backward compatibility).4.4 Regression Tests
5. Impact Assessment
5.1 Performance Impact
5.2 Cost Impact
service_tier = "fast"andreasoning_effort = "low"for compaction reduces token consumption and compute cost per compaction event.5.3 Backward Compatibility
lowreasoning effort andfastservice tier — a sensible improvement over the current behavior.compact_model_reasoning_effortandcompact_service_tierto match their session-level settings.5.4 Risk Assessment
5.5 Files Modified
codex-rs/config/src/config_toml.rscodex-rs/core/src/config/mod.rscodex-rs/core/src/compact.rscodex-rs/core/src/compact_remote.rscodex-rs/core/src/compact_remote_v2.rscodex-rs/core/config.schema.jsoncodex-rs/core/src/config/config_tests.rscodex-rs/core/tests/suite/compact_remote.rsTotal estimated impact: ~140 lines across 8 files.
6. Alternative Approaches Considered
6.1 Hardcode Low Effort + Fast Tier for All Compaction
Pros: Simplest implementation, immediate benefit for all users.
Cons: No user override capability; users who need high-quality compaction cannot opt in.
Verdict: Not recommended. The config-based approach (Phase 1) is better because it provides both automatic improvement and user control.
6.2 Auto-Detect Compaction Complexity
Pros: Dynamically adjusts reasoning effort based on context size.
Cons: Complex to implement correctly; heuristic-based; may produce inconsistent results.
Verdict: Over-engineering. The config-based approach is simpler and more predictable.
6.3 Streaming Progress Indicator for Compaction
Pros: Improves perceived latency.
Cons: Does not address the root cause (actual latency); only masks the problem.
Verdict: Complementary improvement, not a replacement for the primary fix.
7. Recommended Implementation Order
compact_model_reasoning_effortandcompact_service_tiertoConfigToml.Configwith smart defaults (loweffort,fasttier).compact.rs(local compaction) to use compact-specific settings.compact_remote.rs(remote compaction v1) to use compact-specific settings.compact_remote_v2.rs(remote compaction v2) to use compact-specific settings.just write-config-schema.just fix -p codex-coreandjust test -p codex-core.8. References
etraut-openai commentedon Jun 29, 2026
Thanks for reporting this problem. Until recently, Codex used a separate endpoint and server-side logic for compaction. We recently switched to a more robust approach where the compaction logic is moved locally using the same endpoint as normal turns. This eliminates "remote compaction" errors and increases the stability and reliability of compaction operations. If you see further problems with compaction, please use
/feedbackand open a new bug report.