Skip to content

Feature Request: expose caller/session timezone inside Codemode sandbox execution #2072

Description

@joao-cabral

Problem

Codemode's sandboxed JS execution has no way to know the timezone of the
end-user/session driving the agent. new Date() inside the sandbox only
gives server/UTC time, with no IANA timezone context passed through from
useAgent/the calling session.

This breaks any date-boundary logic computed inside codemode (e.g. "today",
"this week") for users outside UTC: the sandbox's "today" is a UTC calendar
day (or a UTC-anchored rolling window), which can diverge from what the
end-user considers "today" in their own timezone — off by several hours
depending on time of day and offset.

Request

Expose the caller's timezone (an IANA string, e.g. from useAgent config/
session) to the codemode sandbox — either:

  • as a pre-run injected global/context value the sandboxed code can read, or
  • as an option on the codemode execution call (e.g. codemode.run(code, { timezone }))

so date-boundary math done inside sandboxed code can be computed correctly
relative to the user's local calendar day instead of always UTC.

Context

We hit this in production: an agent used codemode to compute a "today"
transaction window server-side (UTC-anchored), while our own frontend
computed "today" using the workspace's business timezone. The two disagreed
by a few hours around midnight UTC, producing different transaction counts
for what both surfaces called "today".

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions