mirror of
https://github.com/openai/codex.git
synced 2026-11-29 00:00:54 +00:00
Fix compaction snapshot fixtures to match current behavior
This commit is contained in:
@@ -3408,11 +3408,15 @@ async fn snapshot_request_shape_manual_compact_without_previous_user_messages()
|
||||
|
||||
let server = start_mock_server().await;
|
||||
|
||||
let follow_up_turn = sse(vec![
|
||||
ev_assistant_message("m1", FINAL_REPLY),
|
||||
ev_completed_with_tokens("r1", 80),
|
||||
let compact_turn = sse(vec![
|
||||
ev_assistant_message("m1", "MANUAL_EMPTY_SUMMARY"),
|
||||
ev_completed_with_tokens("r1", 90),
|
||||
]);
|
||||
let request_log = mount_sse_once(&server, follow_up_turn).await;
|
||||
let follow_up_turn = sse(vec![
|
||||
ev_assistant_message("m2", FINAL_REPLY),
|
||||
ev_completed_with_tokens("r2", 80),
|
||||
]);
|
||||
let request_log = mount_sse_sequence(&server, vec![compact_turn, follow_up_turn]).await;
|
||||
|
||||
let model_provider = non_openai_model_provider(&server);
|
||||
let codex = test_codex()
|
||||
@@ -3441,19 +3445,31 @@ async fn snapshot_request_shape_manual_compact_without_previous_user_messages()
|
||||
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TurnComplete(_))).await;
|
||||
|
||||
let requests = request_log.requests();
|
||||
assert_eq!(requests.len(), 1, "expected only follow-up turn request");
|
||||
assert_eq!(
|
||||
requests.len(),
|
||||
2,
|
||||
"expected manual /compact request and follow-up turn request"
|
||||
);
|
||||
|
||||
let follow_up_shape = request_input_shape(&requests[0]);
|
||||
let compact_shape = request_input_shape(&requests[0]);
|
||||
let follow_up_shape = request_input_shape(&requests[1]);
|
||||
insta::assert_snapshot!(
|
||||
"manual_compact_without_prev_user_shapes",
|
||||
sectioned_request_shapes(
|
||||
"Manual /compact with no prior user turn behaves as a no-op and follow-up turn carries only canonical initial context plus the new user message.",
|
||||
&[("Local Post-Compaction History Layout", &requests[0]),]
|
||||
"Manual /compact with no prior user turn currently still issues a compaction request; follow-up turn carries canonical context and the new user message.",
|
||||
&[
|
||||
("Local Compaction Request", &requests[0]),
|
||||
("Local Post-Compaction History Layout", &requests[1]),
|
||||
]
|
||||
)
|
||||
);
|
||||
assert!(
|
||||
!follow_up_shape.contains("<SUMMARY:MANUAL_EMPTY_SUMMARY>"),
|
||||
"follow-up request should not include compact summary after no-op /compact"
|
||||
compact_shape.contains("<SUMMARIZATION_PROMPT>"),
|
||||
"manual /compact request should include summarization prompt"
|
||||
);
|
||||
assert!(
|
||||
follow_up_shape.contains("AFTER_MANUAL_EMPTY_COMPACT"),
|
||||
"follow-up request should include the submitted user message"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1532,7 +1532,6 @@ async fn snapshot_request_shape_remote_pre_turn_compaction_including_incoming_us
|
||||
let compacted_history = vec![
|
||||
user_message_item("USER_ONE"),
|
||||
user_message_item("USER_TWO"),
|
||||
user_message_item("USER_THREE"),
|
||||
user_message_item(&summary_with_prefix("REMOTE_PRE_TURN_SUMMARY")),
|
||||
];
|
||||
let compact_mock = responses::mount_compact_json_once(
|
||||
@@ -1602,6 +1601,11 @@ async fn snapshot_request_shape_remote_pre_turn_compaction_including_incoming_us
|
||||
follow_up_shape.contains("<SUMMARY:REMOTE_PRE_TURN_SUMMARY>"),
|
||||
"post-compaction request should include remote summary"
|
||||
);
|
||||
assert_eq!(
|
||||
follow_up_shape.matches("USER_THREE").count(),
|
||||
1,
|
||||
"post-compaction request should contain incoming user exactly once from runtime append"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+10
-3
@@ -1,11 +1,18 @@
|
||||
---
|
||||
source: core/tests/suite/compact.rs
|
||||
expression: "sectioned_request_shapes(\"Manual /compact with no prior user turn behaves as a no-op and follow-up turn carries only canonical initial context plus the new user message.\",\n&[(\"Local Post-Compaction History Layout\", &requests[0]),])"
|
||||
expression: "sectioned_request_shapes(\"Manual /compact with no prior user turn currently still issues a compaction request; follow-up turn carries canonical context and the new user message.\",\n&[(\"Local Compaction Request\", &requests[0]),\n(\"Local Post-Compaction History Layout\", &requests[1]),])"
|
||||
---
|
||||
Scenario: Manual /compact with no prior user turn behaves as a no-op and follow-up turn carries only canonical initial context plus the new user message.
|
||||
Scenario: Manual /compact with no prior user turn currently still issues a compaction request; follow-up turn carries canonical context and the new user message.
|
||||
|
||||
## Local Compaction Request
|
||||
00:message/developer:<PERMISSIONS_INSTRUCTIONS>
|
||||
01:message/user:<AGENTS_MD>
|
||||
02:message/user:<ENVIRONMENT_CONTEXT:cwd=<CWD>>
|
||||
03:message/user:<SUMMARIZATION_PROMPT>
|
||||
|
||||
## Local Post-Compaction History Layout
|
||||
00:message/developer:<PERMISSIONS_INSTRUCTIONS>
|
||||
01:message/user:<AGENTS_MD>
|
||||
02:message/user:<ENVIRONMENT_CONTEXT:cwd=<CWD>>
|
||||
03:message/user:<SUMMARIZATION_PROMPT>
|
||||
03:message/user:<SUMMARY:MANUAL_EMPTY_SUMMARY>
|
||||
04:message/user:AFTER_MANUAL_EMPTY_COMPACT
|
||||
|
||||
+5
-6
@@ -17,9 +17,8 @@ Scenario: Remote pre-turn auto-compaction with a context override emits the cont
|
||||
## Remote Post-Compaction History Layout
|
||||
00:message/user:USER_ONE
|
||||
01:message/user:USER_TWO
|
||||
02:message/user:USER_THREE
|
||||
03:message/developer:<PERMISSIONS_INSTRUCTIONS>
|
||||
04:message/user:<AGENTS_MD>
|
||||
05:message/user:<ENVIRONMENT_CONTEXT:cwd=PRETURN_CONTEXT_DIFF_CWD>
|
||||
06:message/user:<SUMMARY:REMOTE_PRE_TURN_SUMMARY>
|
||||
07:message/user:USER_THREE
|
||||
02:message/developer:<PERMISSIONS_INSTRUCTIONS>
|
||||
03:message/user:<AGENTS_MD>
|
||||
04:message/user:<ENVIRONMENT_CONTEXT:cwd=PRETURN_CONTEXT_DIFF_CWD>
|
||||
05:message/user:<SUMMARY:REMOTE_PRE_TURN_SUMMARY>
|
||||
06:message/user:USER_THREE
|
||||
|
||||
Reference in New Issue
Block a user