Skip to content

feat(google): Learn longer working hours from past meetings - #2252

Merged
BYK merged 5 commits into
mainfrom
feat/google-saved-working-hours
Nov 20, 2026
Merged

BYK merged 5 commits into
mainfrom
feat/google-saved-working-hours

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Google Calendar's public API does not return the working hours people set in Calendar. So findMeetingTimes used one shared 09:00–17:00 window for everyone. With that window, London and Los Angeles share no time, even when someone in London often takes calls until 22:00.

We decided not to keep a copy of people's hours in Junior. Instead, findMeetingTimes learns longer hours from each person's past meetings:

  • Junior already sent one events.list request per attendee to read the calendar time zone. That request now also returns the attendee's last 3 weeks of events, with only times, transparency, and attendees (no titles or descriptions). This adds no requests.
  • A meeting is a timed, busy event with at least one other attendee that the person did not decline. Blocks that people hold alone, such as "do not schedule" holds, focus time, or personal events, do not count. All-day events do not count. Free/busy still marks every busy block as busy, so slots never go into them.
  • When at least 3 past weekdays had a meeting before 09:00 or after 17:00, the person's hours grow to include that time, rounded out to 30 minutes. The hours never shrink. Meetings on weekends or that cross local midnight are ignored.
  • Each attendee's hours now also set the workday that the slot ranking uses for meeting days and focus time.
  • workday_start/workday_end are now optional. When the requester asks for a time of day, the requested value replaces the learned value.
  • checked[].working_hours reports the hours searched for each person. from_meetings is true when past meetings made the hours longer.
  • When a calendar is shared as free/busy only, Junior cannot see attendees, so that person keeps 09:00–17:00. The eval fixture returns events without attendees, so evals keep 09:00–17:00 too.

Refs #2063

via David Cramer, @BYK.

--

View Session [Sentry]

@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 20, 2026 10:25pm UTC

Request Review

sentry-junior Bot and others added 2 commits October 27, 2026 18:54
Google Calendar does not expose the working hours people set in Calendar,
so findMeetingTimes used one shared 09:00-17:00 window for everyone.

Add setWorkingHours, which saves the requester's own weekday hours in a
new junior_google_working_hours table. findMeetingTimes now searches each
person's saved hours, else 09:00-17:00. A requested time of day can narrow
saved hours but never widen them, and checked[] reports the hours used.

Refs #2063

Co-Authored-By: David Cramer <[email protected]>
Drop the stored working hours. Junior should not keep its own copy of
people's hours.

findMeetingTimes now reads the last 3 weeks of free/busy data in the same
query. When at least 3 past weekdays had a meeting before 09:00 or after
17:00 for a person, their hours grow to include that time. The hours never
shrink, and a time of day that the requester asks for replaces them.

Refs #2063

Co-Authored-By: David Cramer <[email protected]>
@sentry-junior
sentry-junior Bot force-pushed the feat/google-saved-working-hours branch from 2353b40 to f34db5d Compare October 27, 2026 18:54
@sentry-junior sentry-junior Bot changed the title feat(google): Let people save their own working hours for scheduling feat(google): Learn longer working hours from past meetings Oct 27, 2026
Do-not-schedule blocks, focus time, and personal events are busy in
free/busy, so they made people's learned hours longer. Read the last 3
weeks of each person's events instead, in the request that already reads
the calendar time zone. Count only timed, busy events with another
attendee that the person did not decline.

Refs #2063

Co-Authored-By: David Cramer <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@sentry-evals

sentry-evals Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Sentry Evals

junior-behavioral

Run Status Passed Failed Errored Cost Tokens Duration
Head Failed 72 3 0 $1.02 0 440.54s

Base commit b175690 has no eval run to compare against.

junior-integration

Run Status Passed Failed Errored Cost Tokens Duration
Head Passed 101 0 0 $0.97 0 307.99s

Base commit b175690 has no eval run to compare against.

The events field mask asks only for start/dateTime and end/dateTime, so
Google leaves out start and end of all-day events. The history schema
required both, so findMeetingTimes failed for any calendar with an
all-day event in the last 3 weeks. Make them optional and skip such
events.

Refs #2063
@BYK
BYK enabled auto-merge (squash) November 20, 2026 22:04
Port meeting-history working hours onto the new findMeetingTimes
ranking and snake_case tool keys.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e0ed867. Configure here.

singleEvents: "true",
timeMax: new Date(nowMs).toISOString(),
timeMin: new Date(nowMs - HISTORY_MS).toISOString(),
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

History fetch drops recent events

Medium Severity

readCalendar loads three weeks of events with maxResults 250, orderBy startTime, and no pagination. Google still returns working locations, focus time, and other non-meetings in that cap, then drops anything past the oldest 250. Busy calendars therefore lose the most recent meetings, so learned hours stay at 09:00–17:00 and findMeetingTimes misses the late-overlap slots this change exists to find.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e0ed867. Configure here.

self?.responseStatus === "declined"
) {
return [];
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Room bookings count as meetings

Low Severity

A meeting is detected with attendees.length &lt; 2, and the field mask never asks for attendees.resource. A solo conference-room hold therefore looks like a meeting with someone else. Those holds can stretch workdayStart/workdayEnd even though the change is meant to ignore blocks people hold alone. Elsewhere, attendeeResults already drops resource attendees.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e0ed867. Configure here.

@BYK
BYK merged commit 3424e52 into main Nov 20, 2026
52 checks passed
@BYK
BYK deleted the feat/google-saved-working-hours branch November 20, 2026 22:34
dcramer added a commit that referenced this pull request Nov 21, 2026
Daily design docs audit for the commits on `main` up to
f98658436. It checked `attention`, `automations`,
`cache-warming`, `context-compaction`, `child-agents`, `github`,
`sandbox-credentials`, `google`, `inbox`, and `inbox-stacks`. One goal
is clarified and two rules are added.

### New gaps

- `attention.md`: an Automation alert shows only in the dashboard Inbox.
The alert has no linked Conversation
(`packages/junior/src/chat/automations/alert-items.ts`,
`conversationIds: []`), and Slack cards post only to the threads of
linked Conversations
(`packages/junior/src/chat/slack/review-item-card-sync.ts`). A blocked
Automation also gets a plain DM
(`packages/junior/src/chat/automations/blocked-notice.ts`). This breaks
"Slack and the dashboard ask for attention for the same things".
- `inbox.md`: an alert for a blocked Automation or for an unavailable
trigger is `kind: "action"` with no `request` (`alert-items.ts`,
`automationAlert` and the content it builds). It asks no question, but
it counts as needing the creator. This breaks "a notice tells a person
about something that they must fix".

### Intent changes

- `child-agents.md`: a parent wakes only when a child messages it. A
`reply`, a `messageAgent` message, a blocked report, a failure, and the
notice that a paused child dropped Watch Events (#3898)
are all messages. Before, the goal named only `reply`, blocked reports,
and failures.
- `google.md`: new rules for what Junior reads from a colleague's
calendar. These state the current behavior (`list-events.ts`, and
`readCalendar` in `find-meeting-times.ts` from #2252).
They do not change it.

### Gap changes

- `attention.md`: a blocked Automation is no longer listed as an ask
that adds no Review item. #3856 gave it an Automation
alert. The Slack-only part moves to the new gap above.

### Cuts

- `automations.md`: the Automation alert rule listed behavior and
repeated `inbox.md`. Its "offers Run again and Pause" was also wrong for
event Automations, which get only Pause. It now points to the Inbox.
- `inbox.md`: removed the step list and the history from the alert
rules.
- `inbox-stacks.md`: "tenant", the server-snooze mechanism, and the
alert visibility clause that `inbox.md` owns. Rewrapped two long lines.
- `context-compaction.md`: removed the warmup price math that
`cache-warming.md` owns.
- `attention.md`: removed "When Junior is blocked, it says what the
person must do", which repeats the Intent. "push notifications" becomes
"a push", as `TERMINOLOGY.md` says.
- `github.md`: removed the repeats of "never a direct push to the
default branch" and "A person merges it".
- `google.md`: merged the two Google group lines and removed the repeat
of "never uses the Google credentials of the people it helps".

<!-- junior-request-attribution:start -->
via [automation
`sched_5076e4cb686a5e474279137daf734019`](https://junior-prod.sentry.dev/automations/sched_5076e4cb686a5e474279137daf734019)
· Run ID `sched_5076e4cb686a5e474279137daf734019:1795280400000`,
@dcramer.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0CHB3YHES2%3A1795281742.386739 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0CHB3YHES2%3A1795281742.386739)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0CHB3YHES2%3A1795281742.386739/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — e0ed8678 Deployed Nov 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant