Skip to content

Commit f615f09

Browse files
committed
tess
1 parent 919dcc9 commit f615f09

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

codex-rs/core/tests/suite/compact_resume_fork.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@ fn assistant_text_message(text: &str) -> Value {
8282
message_value("assistant", "output_text", text.to_string())
8383
}
8484

85+
fn history_bridge_message(user_messages: &[&str], summary_text: &str) -> Value {
86+
let user_messages_text = if user_messages.is_empty() {
87+
"(none)".to_string()
88+
} else {
89+
user_messages.join("\n\n")
90+
};
91+
let summary_text = if summary_text.is_empty() {
92+
"(no summary available)".to_string()
93+
} else {
94+
summary_text.to_string()
95+
};
96+
let bridge = format!(
97+
"You were originally given instructions from a user over one or more turns. Here were the user messages:\n\n{user_messages_text}\n\nAnother language model started to solve this problem and produced a summary of its thinking process. You also have access to the state of the tools that were used by that language model. Use this to build on the work that has already been done and avoid duplicating work. Here is the summary produced by the other language model, use the information in this summary to assist with your own analysis:\n\n{summary_text}"
98+
);
99+
user_text_message(&bridge)
100+
}
101+
85102
fn format_environment_context(
86103
cwd: Option<std::path::PathBuf>,
87104
approval_policy: Option<AskForApproval>,
@@ -333,12 +350,13 @@ async fn compact_resume_and_fork_preserve_model_history_view() {
333350
.clone();
334351

335352
let initial_context = initial_context_messages(&config).await;
353+
let bridge_message = history_bridge_message(&["hello world"], SUMMARY_TEXT);
336354

337355
let expected_prior_history_after_compact = initial_context
338356
.iter()
339357
.cloned()
340358
.chain(vec![
341-
assistant_text_message(SUMMARY_TEXT),
359+
bridge_message.clone(),
342360
user_text_message("AFTER_COMPACT"),
343361
])
344362
.collect::<Vec<_>>();
@@ -347,7 +365,7 @@ async fn compact_resume_and_fork_preserve_model_history_view() {
347365
.iter()
348366
.cloned()
349367
.chain(vec![
350-
assistant_text_message(SUMMARY_TEXT),
368+
bridge_message.clone(),
351369
user_text_message("AFTER_COMPACT"),
352370
assistant_text_message("AFTER_COMPACT_REPLY"),
353371
user_text_message("AFTER_RESUME"),
@@ -358,7 +376,7 @@ async fn compact_resume_and_fork_preserve_model_history_view() {
358376
.iter()
359377
.cloned()
360378
.chain(vec![
361-
assistant_text_message(SUMMARY_TEXT),
379+
bridge_message,
362380
user_text_message("AFTER_COMPACT"),
363381
assistant_text_message("AFTER_COMPACT_REPLY"),
364382
user_text_message("AFTER_FORK"),

0 commit comments

Comments
 (0)