Make environment context date and timezone configurable (#52164)

## What changed

Add `include_environment_context_time`, enabled by default. Setting it to `false` omits `<current_date>` and `<timezone>` while retaining the rest of the environment context, and skips the clock read used to populate the date.

## Testing

Extend configuration, session context, and external time provider tests to cover enabled and disabled time fields, context updates across turns, and current-time reminder behavior.

GitOrigin-RevId: 5071ce1701c044b680624d0cdbba7e0bc2b5bbe6
This commit is contained in:
surajs-oai
2026-10-08 16:27:10 +00:00
committed by copyberry
parent cd85a26cae
commit 8c818cbed4
11 changed files with 75 additions and 24 deletions
+8 -1
View File
@@ -10265,9 +10265,14 @@ async fn record_context_updates_emits_environment_item_for_cwd_changes() {
assert!(!environment_update.contains("<environments>"));
}
#[test_case::test_case(true; "with_time")]
#[test_case::test_case(false; "without_time")]
#[tokio::test]
async fn record_context_updates_use_environment_permission_profile_and_workspace_roots() {
async fn record_context_updates_use_environment_permission_profile_and_workspace_roots(
include_time: bool,
) {
let (session, mut previous_context) = make_session_and_context().await;
Arc::make_mut(&mut previous_context.config).include_environment_context_time = include_time;
Arc::make_mut(&mut previous_context.config)
.permissions
.set_permission_profile(PermissionProfile::Disabled)
@@ -10332,6 +10337,8 @@ async fn record_context_updates_use_environment_permission_profile_and_workspace
&& environment_update.contains(workspace_root.to_string_lossy().as_ref()),
"selected environment permissions should be visible: {environment_update}"
);
assert_eq!(environment_update.contains("<current_date"), include_time);
assert_eq!(environment_update.contains("<timezone"), include_time);
}
#[tokio::test]
+12 -9
View File
@@ -264,15 +264,18 @@ impl Session {
));
}
if turn_context.config.include_environment_context {
let current_date = self
.read_clock_for_context(turn_context, "environment_date")
.await?
.map(|current_time| {
current_time
.with_timezone(&chrono::Local)
.format("%Y-%m-%d")
.to_string()
});
let current_date = if turn_context.config.include_environment_context_time {
self.read_clock_for_context(turn_context, "environment_date")
.await?
.map(|current_time| {
current_time
.with_timezone(&chrono::Local)
.format("%Y-%m-%d")
.to_string()
})
} else {
None
};
world_state.add_section(
EnvironmentsState::from_turn_context_with_environments(
turn_context,