Skip to content

feat: add local date/timezone to turn environment context#12947

Merged
celia-oai merged 4 commits intomainfrom
dev/cc/timezone
Feb 26, 2026
Merged

feat: add local date/timezone to turn environment context#12947
celia-oai merged 4 commits intomainfrom
dev/cc/timezone

Conversation

@celia-oai
Copy link
Collaborator

@celia-oai celia-oai commented Feb 26, 2026

Summary

This PR includes the session's local date and timezone in the model-visible environment context and persists that data in TurnContextItem.

What changed

  • captures the current local date and IANA timezone when building a turn context, with a UTC fallback if the timezone lookup fails
  • includes current_date and timezone in the serialized <environment_context> payload
  • stores those fields on TurnContextItem so they survive rollout/history handling, subagent review threads, and resume flows
  • treats date/timezone changes as environment updates, so prompt caching and context refresh logic do not silently reuse stale time context
  • updates tests to validate the new environment fields without depending on a single hardcoded environment-context string

test

built a local build and saw it in the rollout file:

{"timestamp":"2026-02-26T21:39:50.737Z","type":"response_item","payload":{"type":"message","role":"user","content":[{"type":"input_text","text":"<environment_context>\n  <shell>zsh</shell>\n  <current_date>2026-02-26</current_date>\n  <timezone>America/Los_Angeles</timezone>\n</environment_context>"}]}}

@celia-oai celia-oai marked this pull request as ready for review February 26, 2026 22:06
icu_provider = { version = "2.1", features = ["sync"] }
ignore = "0.4.23"
image = { version = "^0.25.9", default-features = false }
iana-time-zone = "0.1.64"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a huge dep?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codex says:

• No. In this workspace it is not a huge dependency.

iana-time-zone = "0.1.64" is a small platform abstraction crate for getting the local IANA time zone. Also, that manifest entry is a semver range, so the lockfile currently resolves it to 0.1.65, not exactly 0.1.64.

What matters here:

  • On this macOS workspace, cargo tree -p iana-time-zone shows it resolves to just core-foundation-sys.
  • The lockfile lists Android/wasm/Windows helpers too, but those are target-specific, not all compiled on this platform.
  • It is already in the graph via chrono, so in this repo the incremental cost is effectively negligible.

@celia-oai celia-oai requested a review from pakrym-oai February 26, 2026 22:12
@celia-oai celia-oai enabled auto-merge (squash) February 26, 2026 22:46
@celia-oai celia-oai merged commit 90cc4e7 into main Feb 26, 2026
73 of 77 checks passed
@celia-oai celia-oai deleted the dev/cc/timezone branch February 26, 2026 23:17
@github-actions github-actions bot locked and limited conversation to collaborators Feb 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants