mirror of
https://github.com/openai/codex.git
synced 2026-10-18 17:18:52 +00:00
Tag current time reminders in model context (#38443)
## What changed - Wrap injected current time reminders in `<current_time_reminder>` tags. - Keep direct `clock.curr_time` tool output and log previews as plain text. ## Testing - Update core and app-server coverage for tagged reminders and untagged tool output. GitOrigin-RevId: ad27f1fa10cca7f83d1ac731e01255320bb60f47
This commit is contained in:
@@ -26,7 +26,8 @@ const DEFAULT_READ_TIMEOUT: Duration = Duration::from_secs(25);
|
||||
#[cfg(not(windows))]
|
||||
const DEFAULT_READ_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
const CURRENT_TIME_AT: i64 = 1_781_717_655;
|
||||
const CURRENT_TIME_REMINDER: &str = "It is 2026-06-17 17:34:15 UTC.";
|
||||
const CURRENT_TIME_REMINDER: &str =
|
||||
"<current_time_reminder>It is 2026-06-17 17:34:15 UTC.</current_time_reminder>";
|
||||
|
||||
#[tokio::test]
|
||||
async fn current_time_read_round_trip_adds_reminder_to_model_input() -> Result<()> {
|
||||
|
||||
@@ -29,7 +29,7 @@ impl ContextualUserFragment for CurrentTimeReminder {
|
||||
}
|
||||
|
||||
fn type_markers() -> (&'static str, &'static str) {
|
||||
("", "")
|
||||
("<current_time_reminder>", "</current_time_reminder>")
|
||||
}
|
||||
|
||||
fn body(&self) -> String {
|
||||
|
||||
@@ -26,7 +26,7 @@ struct CurrentTimeOutput(CurrentTimeReminder);
|
||||
|
||||
impl ToolOutput for CurrentTimeOutput {
|
||||
fn log_preview(&self) -> String {
|
||||
self.0.render()
|
||||
self.0.body()
|
||||
}
|
||||
|
||||
fn success_for_logging(&self) -> bool {
|
||||
@@ -34,8 +34,7 @@ impl ToolOutput for CurrentTimeOutput {
|
||||
}
|
||||
|
||||
fn to_response_item(&self, call_id: &str, payload: &ToolPayload) -> ResponseInputItem {
|
||||
FunctionToolOutput::from_text(self.0.render(), Some(true))
|
||||
.to_response_item(call_id, payload)
|
||||
FunctionToolOutput::from_text(self.0.body(), Some(true)).to_response_item(call_id, payload)
|
||||
}
|
||||
|
||||
fn code_mode_result(&self, _payload: &ToolPayload) -> JsonValue {
|
||||
|
||||
@@ -41,10 +41,14 @@ use core_test_support::wait_for_event;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::json;
|
||||
|
||||
const FIRST_REMINDER: &str = "It is 2026-06-17 17:34:15 UTC.";
|
||||
const EARLIER_REMINDER: &str = "It is 2026-06-17 17:33:15 UTC.";
|
||||
const SECOND_REMINDER: &str = "It is 2026-06-17 17:35:15 UTC.";
|
||||
const THIRD_REMINDER: &str = "It is 2026-06-17 17:36:15 UTC.";
|
||||
const FIRST_REMINDER: &str =
|
||||
"<current_time_reminder>It is 2026-06-17 17:34:15 UTC.</current_time_reminder>";
|
||||
const EARLIER_REMINDER: &str =
|
||||
"<current_time_reminder>It is 2026-06-17 17:33:15 UTC.</current_time_reminder>";
|
||||
const SECOND_REMINDER: &str =
|
||||
"<current_time_reminder>It is 2026-06-17 17:35:15 UTC.</current_time_reminder>";
|
||||
const THIRD_REMINDER: &str =
|
||||
"<current_time_reminder>It is 2026-06-17 17:36:15 UTC.</current_time_reminder>";
|
||||
const FIRST_TIME_UNIX_SECONDS: i64 = 1_781_717_655;
|
||||
|
||||
struct TestTimeProvider {
|
||||
@@ -93,7 +97,7 @@ fn current_time_reminders(request: &ResponsesRequest) -> Vec<String> {
|
||||
request
|
||||
.message_input_texts("developer")
|
||||
.into_iter()
|
||||
.filter(|text| text.starts_with("It is "))
|
||||
.filter(|text| text.starts_with("<current_time_reminder>"))
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -340,7 +344,7 @@ async fn system_time_source_adds_current_time_reminder() -> Result<()> {
|
||||
let reminders = current_time_reminders(&responses.single_request());
|
||||
assert_eq!(reminders.len(), 1);
|
||||
assert_regex_match(
|
||||
r"^It is \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} UTC\.$",
|
||||
r"^<current_time_reminder>It is \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} UTC\.</current_time_reminder>$",
|
||||
&reminders[0],
|
||||
);
|
||||
|
||||
@@ -495,7 +499,7 @@ async fn current_time_tool_returns_the_latest_time() -> Result<()> {
|
||||
);
|
||||
assert_eq!(
|
||||
requests[1].function_call_output_text(CALL_ID),
|
||||
Some(SECOND_REMINDER.to_string())
|
||||
Some("It is 2026-06-17 17:35:15 UTC.".to_string())
|
||||
);
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user