Skip to content

fix(query_incidents): make the since/until time window optional#67

Merged
ysyneu merged 2 commits into
mainfrom
fix/query-incidents-time-window
Jun 10, 2026
Merged

fix(query_incidents): make the since/until time window optional#67
ysyneu merged 2 commits into
mainfrom
fix/query-incidents-time-window

Conversation

@ysyneu

@ysyneu ysyneu commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Why

In prod AI-SRE session sess_f2NLHa2qUpTnUnJRJmSMp3 the agent asked our official MCP for current severe incidents (severity + progress, no time window) and query_incidents rejected it with both since and until are required — a failure mode the code itself flagged in a comment. "Find current open incidents" with no window is a common, reasonable ask and shouldn't error.

What

  • both omitted → default to the last 30 days (DefaultIncidentWindow), comfortably under the backend's 31-day span cap.
  • only until given (since omitted) → still errors, fast, without hitting the backend — a one-sided window is a real mistake, not something to paper over by inventing a since.
  • bare since → unchanged: until keeps defaulting to "now".
  • The shared validateTimeWindow is untouched, so query_changes and other callers are unaffected. The per-tool description documents the 30-day default.

Tests

  • TestQueryIncidentsDefaultsWindowWhenOmitted — the exact reported case (severity + progress, no window) now succeeds with a ~30d window inside MaxTimeWindow.
  • TestQueryIncidentsOnlyUntilErrors — one-sided window still errors, no backend call.
  • TestQueryIncidentsBareSinceDefaultsUntilToNow — bare since still works.
  • go build ./... clean; all QueryIncidents tests green.

Companion PRs (same incident)

  • flashduty-runner: bash CWD defaults to workspace root + no more opaque EOF (fix/envd-cwd-and-write-eofmain).
  • fc-safari: cloud RemoteEnvironment reads envd's real workspace root + clearer path errors (fix/cloud-workspace-rootfeat/ai-sre).

ysyneu added 2 commits June 9, 2026 23:16
"Find current open incidents" with no time window is a common, reasonable
ask, but query_incidents hard-required both since and until and rejected it
with "both since and until are required" (a failure mode the code itself
flagged in a comment). Now: both omitted -> default to the last 30 days
(under the backend's 31-day span cap); only `until` given -> still errors;
a bare `since` keeps the existing "until defaults to now" behavior. The
shared validateTimeWindow is unchanged, so query_changes is unaffected.
The per-tool since/until descriptions duplicated the whole shared
date-format guidance just to prepend OPTIONAL, which would drift from
SinceDescription/UntilDescription over time. The only tool-specific fact
is the both-omitted 30-day default, so compose incidentSinceDescription
from the shared SinceDescription + that one sentence, and revert until to
the shared WithUntil() (it already documents its now default). Behavior
is unchanged; the handler default is what actually fixes the bug.
@ysyneu ysyneu merged commit 8e1f969 into main Jun 10, 2026
11 of 13 checks passed
@ysyneu ysyneu deleted the fix/query-incidents-time-window branch June 10, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant