From 3ba52d6075bb69795d008d427139c28fdebdb436 Mon Sep 17 00:00:00 2001 From: rka-oai Date: Thu, 13 Aug 2026 21:46:31 +0000 Subject: [PATCH] Tag current time reminders in model context (#38443) ## What changed - Wrap injected current time reminders in `` 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 --- .../app-server/tests/suite/v2/current_time.rs | 3 ++- .../core/src/context/current_time_reminder.rs | 2 +- .../core/src/tools/handlers/current_time.rs | 5 ++--- .../core/tests/suite/current_time_reminder.rs | 18 +++++++++++------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/codex-rs/app-server/tests/suite/v2/current_time.rs b/codex-rs/app-server/tests/suite/v2/current_time.rs index 9f8ae49d46..d311acd9a7 100644 --- a/codex-rs/app-server/tests/suite/v2/current_time.rs +++ b/codex-rs/app-server/tests/suite/v2/current_time.rs @@ -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 = + "It is 2026-06-17 17:34:15 UTC."; #[tokio::test] async fn current_time_read_round_trip_adds_reminder_to_model_input() -> Result<()> { diff --git a/codex-rs/core/src/context/current_time_reminder.rs b/codex-rs/core/src/context/current_time_reminder.rs index 0baf56b281..7b6b61da5c 100644 --- a/codex-rs/core/src/context/current_time_reminder.rs +++ b/codex-rs/core/src/context/current_time_reminder.rs @@ -29,7 +29,7 @@ impl ContextualUserFragment for CurrentTimeReminder { } fn type_markers() -> (&'static str, &'static str) { - ("", "") + ("", "") } fn body(&self) -> String { diff --git a/codex-rs/core/src/tools/handlers/current_time.rs b/codex-rs/core/src/tools/handlers/current_time.rs index d03e7ffb0a..983e33e23d 100644 --- a/codex-rs/core/src/tools/handlers/current_time.rs +++ b/codex-rs/core/src/tools/handlers/current_time.rs @@ -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 { diff --git a/codex-rs/core/tests/suite/current_time_reminder.rs b/codex-rs/core/tests/suite/current_time_reminder.rs index 44fe2ad6c1..2cdac3c78e 100644 --- a/codex-rs/core/tests/suite/current_time_reminder.rs +++ b/codex-rs/core/tests/suite/current_time_reminder.rs @@ -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 = + "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_TIME_UNIX_SECONDS: i64 = 1_781_717_655; struct TestTimeProvider { @@ -93,7 +97,7 @@ fn current_time_reminders(request: &ResponsesRequest) -> Vec { request .message_input_texts("developer") .into_iter() - .filter(|text| text.starts_with("It is ")) + .filter(|text| text.starts_with("")) .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"^It is \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} UTC\.$", &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(())