Refresh environment dates from the configured clock (#36187)

## Why

The `<current_date>` in environment context could diverge from the clock used by current-time features, especially when a host provides an external clock.

## What changed

- Read the current time from the session's time provider whenever world state is built, and render its local date in environment context.
- Use each session's own thread ID for clock reads, including guardian sessions.
- Propagate clock-read failures through turn error events and stop before model inference.

## Testing

- Cover date updates across turns and app-server requests.
- Verify guardian clock reads use the corresponding root or guardian thread ID and do not run during prewarm.
- Verify clock failures emit an error without sending an inference request.

GitOrigin-RevId: bb7f32ccc0229b7bc6f14d7356db00bcce78066d
This commit is contained in:
rka-oai authored and copyberry committed 2026-07-30 16:44:18 +00:00
1 parent 483559cc75
commit 9eeac78b3f
16 files changed
+283 -68

No files matched your search

+2 -2
View File
@@ -40,7 +40,7 @@ pub(crate) async fn run_manual_compact_task(
let step_context = sess
.capture_step_context(Arc::clone(&turn_context), &CancellationToken::new())
.await?;
let world_state = Arc::new(sess.build_world_state_for_step(&step_context).await);
let world_state = Arc::new(sess.build_world_state_for_step(&step_context).await?);
run_compact_task_inner(&sess, &step_context, world_state, CompactionTrigger::Manual).await
}
@@ -57,7 +57,7 @@ pub(crate) async fn run_inline_auto_compact_task(
let world_state = match initial_context_injection {
InitialContextInjection::BeforeLastUserMessage { world_state, .. } => world_state,
InitialContextInjection::DoNotInject => {
Arc::new(sess.build_world_state_for_step(&step_context).await)
Arc::new(sess.build_world_state_for_step(&step_context).await?)
}
};
run_compact_task_inner(&sess, &step_context, world_state, CompactionTrigger::Auto).await