WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@Galaxy-0
Copy link
Contributor

Description

This PR addresses Issue #8402 (Context pruning hangs on large overflow) by implementing a "Smart Batch Pruning" strategy.

Problem

Previous logic removed history items one-by-one upon ContextWindowExceeded. When the overflow was significant (e.g., due to a large tool output), this resulted in hundreds of inefficient retries, causing the system to hang.

Fix

Modified run_compact_task_inner in core/src/compact.rs to prune ~10% of history items (minimum 1) at once. This significantly speeds up convergence to a valid context size and helps clear "invisible" items (like Ghost Snapshots) that might accumulate at the head of the history.

Testing Status

  • Static Analysis: cargo check -p codex-core PASSED.
  • Runtime Testing: NOT Verified locally. Due to the difficulty of reproducing specific context overflow conditions and mocking the LLM error responses in the local environment, runtime behavior has not been explicitly verified via unit/integration tests. Explicit review of the logic change is recommended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant