mirror of
https://github.com/openai/codex.git
synced 2026-04-28 16:45:54 +00:00
67 lines
1.6 KiB
Markdown
67 lines
1.6 KiB
Markdown
# PR #2746: Race condition in compact
|
|
|
|
- URL: https://github.com/openai/codex/pull/2746
|
|
- Author: aibrahim-oai
|
|
- Created: 2025-08-27 03:02:39 UTC
|
|
- Updated: 2025-08-28 19:53:10 UTC
|
|
- Changes: +6/-3, Files changed: 1, Commits: 56
|
|
|
|
## Description
|
|
|
|
This fixes the flakiness in `summarize_context_three_requests_and_instructions` because we should trim history before sending task complete.
|
|
|
|
## Full Diff
|
|
|
|
```diff
|
|
diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs
|
|
index 365969ac02..8443c534fb 100644
|
|
--- a/codex-rs/core/src/codex.rs
|
|
+++ b/codex-rs/core/src/codex.rs
|
|
@@ -1884,6 +1884,12 @@ async fn run_compact_task(
|
|
}
|
|
|
|
sess.remove_task(&sub_id);
|
|
+
|
|
+ {
|
|
+ let mut state = sess.state.lock_unchecked();
|
|
+ state.history.keep_last_messages(1);
|
|
+ }
|
|
+
|
|
let event = Event {
|
|
id: sub_id.clone(),
|
|
msg: EventMsg::AgentMessage(AgentMessageEvent {
|
|
@@ -1898,9 +1904,6 @@ async fn run_compact_task(
|
|
}),
|
|
};
|
|
sess.send_event(event).await;
|
|
-
|
|
- let mut state = sess.state.lock_unchecked();
|
|
- state.history.keep_last_messages(1);
|
|
}
|
|
|
|
async fn handle_response_item(
|
|
```
|
|
|
|
## Review Comments
|
|
|
|
### codex-rs/core/src/codex.rs
|
|
|
|
- Created: 2025-08-28 00:04:09 UTC | Link: https://github.com/openai/codex/pull/2746#discussion_r2305647319
|
|
|
|
```diff
|
|
@@ -1873,6 +1879,9 @@ async fn run_compact_task(
|
|
}
|
|
|
|
sess.remove_task(&sub_id);
|
|
+
|
|
+ sess.trim_history_to_last_messages(1);
|
|
```
|
|
|
|
> Should we just inline this since it is only called once?
|
|
>
|
|
> ```
|
|
> {
|
|
> let mut state = sess.state.lock_unchecked();
|
|
> state.history.keep_last_messages(1);
|
|
> }
|
|
> ``` |