Skip to content

Rework quiet-hours/time awareness: surface time to agent/tools, don't enforce in control plane #17459

@markojak

Description

@markojak

Context / regression

Quiet hours should not be a control-plane policy that silently withholds or delays agent actions. Per the tool-use principles we want the agent to see the relevant runtime facts and make/justify the decision, not have a background subsystem enforce user-contact policy invisibly.

The current direction is fragmented:

Goal

Move from control-plane quiet-hours enforcement to agent-visible, timezone-aware tool context:

  1. Fix the caching regression(s).
  2. Give the agent reliable current time + user timezone context on every turn and on relevant tool calls.
  3. For time-sensitive tools (email, calendars, agent mailbox, send/wait/scheduler-style tools, future autonomy/watch tools), surface a clear advisory when the action appears outside the user's normal contact window — but do not block or delay it in the control plane.

Proposed design

1. Stable prompt cache, live time outside the cached system prompt

  • Keep the cached system prompt byte-stable across turns.
  • Replace the ambiguous Conversation started: mental model with a stable session-start anchor only.
  • Inject volatile time context through the existing ephemeral user-message context path, e.g.
Runtime time context:
- Current time: 2026-04-29 08:34:12 America/Los_Angeles (UTC-07:00)
- User timezone: America/Los_Angeles
- Session started: 2026-04-29 08:00:02 America/Los_Angeles

2. Tool-runtime time advisory, not enforcement

Add a small shared helper/context object available to tool handlers, for example:

ToolRuntimeTimeContext(
    now=<aware datetime>,
    user_timezone="America/Los_Angeles",
    contact_window=("08:00", "23:00"),
    within_contact_window=True | False,
    advisory="It is 02:14 in the user's timezone; this may be outside their normal contact window. Ask/consider deferring unless urgent."
)

Tools may include this in their returned JSON/result text when relevant. The control plane must not silently suppress, defer, or rewrite the action.

Examples:

  • wait / process.wait / future agent-mailbox wait:
    • Return current local time and deadline/elapsed-time interpretation.
    • If waiting would cross the user's normal contact window, warn the agent.
  • Email/calendar/mailbox tools:
    • Include current_time, user_timezone, and contact_window_advisory in reads/searches and before sends/creates where relevant.
  • send_message / proactive delivery paths:
    • Warn if sending outside the window; do not block. The agent can explicitly say why it is sending now or choose to schedule/defer.

3. Remove/avoid control-plane quiet-hours semantics

  • No core gateway/scheduler/autonomy subsystem should silently hold messages merely because of quiet hours.
  • If a subsystem keeps a user-configured contact window, it should expose that as agent context/advisory only.
  • Any future hard block must be a separate, explicit user-configured safety setting with visible tool feedback, not the default quiet-hours behavior.

Implementation slices

  1. Immediate cache correctness

  2. Core time context consolidation

  3. Tool runtime advisory helper

    • Add a shared helper for aware now, resolved user timezone, configurable advisory window, and advisory text.
    • Wire it into time-sensitive tools first: wait/process-wait, email/calendar/agent-mailbox if present, send/proactive-delivery surfaces.
    • Ensure tool output is advisory and visible to the model.
  4. Docs / principles alignment

    • Document: "time policy is surfaced to the agent; control plane does not silently enforce quiet hours."
    • Add tests that verify no quiet-hours path silently suppresses delivery/action without returning an advisory to the agent.

Acceptance criteria

  • get_tool_definitions(quiet_mode=True) cache pollution is fixed; repeated Gateway agents do not accumulate duplicate tool schemas.
  • Current time + user timezone are available on every agent turn without mutating the cached system prompt.
  • Prompt-cache stability tests prove volatile time context is excluded from the cached system prompt.
  • Time-sensitive tools return explicit time/timezone/advisory metadata when appropriate.
  • Quiet-hours/contact-window behavior is advisory by default and visible to the agent; no default control-plane suppression/delay.
  • Duplicate timestamp-prefix/current-time PRs are either closed as superseded or rebased into the chosen core path.
  • Docs explain the principle and the intended extension point for future tools.

Non-goals

  • Building a full policy engine.
  • Adding a broad autonomy control plane.
  • Hard-blocking sends/actions outside contact windows by default.
  • Moving volatile time data into the system prompt.

Suggested priority

P1. This blocks reliable gateway use because caching/schema pollution is already user-visible (#17335), and the quiet-hours direction is an architectural regression if it lands as hidden control-plane enforcement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/agentCore agent loop, run_agent.py, prompt buildercomp/gatewayGateway runner, session dispatch, deliverytype/refactorCode restructuring, no behavior change

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions