Skip to content

fix(den-api): accept RFC 3339 offsets for Calendar and expose query constraints in search_capabilities - #4377

Merged
benjaminshafii merged 1 commit into
devfrom
fix/capability-query-schema-hints
Sep 4, 2026
Merged

benjaminshafii merged 1 commit into
devfrom
fix/capability-query-schema-hints

Conversation

@benjaminshafii

Copy link
Copy Markdown
Member

Why

Two recurring agent failures against the Google Workspace native capabilities, pulled from real OpenWork session history:

  1. Invalid ISO datetime on Calendar — hit in 7+ sessions since Jul 29 (getCapabilitiesGoogleWorkspaceCalendarEvents timeMin/timeMax, postCapabilitiesGoogleWorkspaceCalendarEvents start/end). The model sends a valid RFC 3339 timestamp with an offset (2026-09-03T17:00:00+02:00); the route used z.string().datetime(), whose default offset: false only accepts a trailing Z. Google Calendar accepts offsets, so we were stricter than upstream, and the description gave no hint.
  2. Gmail maxResults cap invisible to the model — the route enforces .max(25) and even documents "capped at 25", but search_capabilities returned query hints as a live Zod object (inputSchema: operation.inputSchema) that JSON.stringify dumps as {"def":{"type":"number","checks":[]}} — constraints stripped, so the model asks for 50 and gets too_big.

What

  • routes/org/google-workspace.ts: z.string().datetime({ offset: true }) on the four Calendar fields; descriptions now state "RFC 3339 date-time with a UTC offset or Z" with an example.
  • mcp/catalog.ts: new getQueryParameterSchema(operation) — plain JSON Schema { type: "object", properties, required? } built from the OpenAPI query parameters, which already carry minimum/maximum/default/format/required/description.
  • mcp/search.ts, mcp/native-capabilities.ts: emit querySchema next to bodySchema; drop the leaked inputSchema.
  • mcp/agent.ts: declare querySchema in the output schema; tool description lists it.

Out of scope (follow-up): microsoft-365.ts has the same .datetime() on timeMin/timeMax/start/end, but Graph's event-create dateTimeTimeZone.dateTime is offset-less, so widening it needs a conversion step rather than a validator change.

Proof

Spec: evals/specs/google-workspace-connector-retrieval.test.ts (extended; wraps the den-api bun suite and pins test names). New den-api tests, each with its negative half:

  • calendar events list accepts RFC 3339 offsets and forwards them verbatim — 200 and fake Google receives +02:00 unchanged; 2026-09-03 00:00 → 400 invalid_request, Google not called.
  • calendar event create accepts RFC 3339 offsets and forwards them verbatim — start.dateTime/end.dateTime forwarded verbatim; 2026-09-03T17:00 → 400, Google not called.
  • search_capabilities exposes query parameter constraints as JSON schema instead of leaked validator internals — real MCP tools/call: Gmail querySchema.properties.maxResults = {integer, min 1, max 25, default 10, "capped at 25"}; Calendar required: [timeMin, timeMax], format: date-time, description contains +02:00; no inputSchema key; no "checks":/"def": in the serialized match or text; Gmail drafts (no query params) has no querySchema.
  • native-capabilities.test.ts — replaced the assertion that locked in the leak by reference identity.

Lane: local fallback (no Daytona credentials in this shell); cold boot, no OPENWORK_EVAL_DEN_API_URL.

pnpm evals:pr specs/google-workspace-connector-retrieval.test.ts   # exit 0 — 1 passed, 0 skipped
bun test test/google-workspace-capabilities.test.ts                # exit 0 — 50 pass, 0 fail (47 → 50)
bun test test/native-capabilities.test.ts                          # exit 0 — 7 pass
bun test test/mcp-agent-timeouts.test.ts                           # exit 0 — 15 pass
tsc -p tsconfig.json --noEmit                                      # exit 0

Pre-existing, reproduced on a clean origin/dev (431c8ce) control worktree with the same commands: test/mcp-agent-config-policy.test.ts 14 pass / 2 fail (same two discovery tests), and running google-workspace-capabilities + native-capabilities in one bun invocation → 2 fake-Google env collisions in native capability execute. Neither is touched by this diff.

Verdict: Passed.

@vercel

vercel Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 4, 2026 12:22am UTC
openwork-den Ready Ready Preview Sep 4, 2026 12:22am UTC
openwork-diagnostics Ready Ready Preview Sep 4, 2026 12:22am UTC
openwork-landing Ready Ready Preview, v0 Sep 4, 2026 12:22am UTC

@benjaminshafii

Copy link
Copy Markdown
Member Author

Test evidence — google-workspace-retrieval-enforces-drive-access-and-bounds-model-visible-output — ✅ passed

✅ passed · 4 expectations passed · 0 failed · 0 pending

verdict passed · 0 user observations · 0 probes · steps 0/0

ℹ️ ASSERTION — 1. General Drive retrieval requires a verified read grant

The focused connector suite proves selected-file access cannot call general Drive search or read, missing grants fail closed, and the same file created directly in My Drive succeeds with read-only or full Drive access. Provider authorization failures remain actionable, file-read 404s remain bounded and ambiguous, folders stop after metadata without traversal, and Shared Drive flags are sent as a separate compatibility correction.

  • ✅ PASS General Drive retrieval requires a verified read grant — The focused connector suite proves selected-file access cannot call general Drive search or read, missing grants fail closed, and the same file created directly in My Drive succeeds with read-only or full Drive access. Provider authorization failures remain actionable, file-read 404s remain bounded and ambiguous, folders stop after metadata without traversal, and Shared Drive flags are sent as a separate compatibility correction.

ℹ️ ASSERTION — 2. Gmail metadata retrieval overlaps bounded requests without reordering results

Six delayed metadata requests overlap with a maximum concurrency of four while the response remains in the original Gmail list order.

  • ✅ PASS Gmail metadata retrieval overlaps bounded requests without reordering results — Six delayed metadata requests overlap with a maximum concurrency of four while the response remains in the original Gmail list order.

ℹ️ ASSERTION — 3. The existing MCP path keeps model-visible connector output bounded

A real search_capabilities and execute_capability journey omits oversized non-image base64 before download where metadata permits, preserves existing small attachment bytes, compacts large JSON, and applies model-visible text limits to Drive and Gmail content without reducing their retrieval-layer limits.

  • ✅ PASS The existing MCP path keeps model-visible connector output bounded — A real search_capabilities and execute_capability journey omits oversized non-image base64 before download where metadata permits, preserves existing small attachment bytes, compacts large JSON, and applies model-visible text limits to Drive and Gmail content without reducing their retrieval-layer limits.

ℹ️ ASSERTION — 4. Calendar datetimes accept RFC 3339 offsets and search hints expose real query constraints

Calendar list and create accept RFC 3339 UTC offsets, forward them unchanged, and reject malformed local datetimes without calling Google. MCP search returns plain JSON Schema constraints and descriptions for Gmail and Calendar query parameters without leaking validator internals or adding query schemas to operations without query parameters.

  • ✅ PASS Calendar datetimes accept RFC 3339 offsets and search hints expose real query constraints — Calendar list and create accept RFC 3339 UTC offsets, forward them unchanged, and reject malformed local datetimes without calling Google. MCP search returns plain JSON Schema constraints and descriptions for Gmail and Calendar query parameters without leaking validator internals or adding query schemas to operations without query parameters.

Test run created 2026-09-03T23:01:10.611Z · Source: evals/results/test-runs/2026-09-03T23-01-10-611Z-google-workspace-retrieval-enforces-drive-access-and-bounds-model-visible-output/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4377 --test-run 2026-09-03T23-01-10-611Z-google-workspace-retrieval-enforces-drive-access-and-bounds-model-visible-output

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (a7ad0275b9edea7a019bfee30a5593d2ac98547c). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

…onstraints in search_capabilities

Google Calendar timeMin/timeMax/start/end used z.string().datetime(),
which only accepts a trailing Z, so every offset timestamp the agent
naturally produced (2026-09-03T17:00:00+02:00) failed with
"Invalid ISO datetime" even though Google accepts it. Widen to
{ offset: true } and state the format in each description.

search_capabilities returned query hints as a live Zod object
(inputSchema) that JSON.stringify dumped as {"def":{...,"checks":[]}},
dropping constraints like Gmail maxResults <= 25. Replace it with a
querySchema built from the OpenAPI query parameters, which already carry
minimum/maximum/default/format/required/description.

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (61bd83afed6a6571b754266d2f89683003ebec07). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@benjaminshafii
benjaminshafii merged commit e17e441 into dev Sep 4, 2026
35 of 37 checks passed

This branch was successfully deployed

4 active deployments
Preview – openwork-landing — 61bd83af Deployed Sep 4, 2026 by vercel[bot]
Preview – openwork-den — 61bd83af Deployed Sep 4, 2026 by vercel[bot]
Preview – openwork-app — 61bd83af Deployed Sep 4, 2026 by vercel[bot]
Preview – openwork-diagnostics — 61bd83af Deployed Sep 4, 2026 by vercel[bot]
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