Skip to content

feat(gmail): one drafts capability with declarative, host-fulfilled attachments (SEP-2356 shape) - #3657

Closed
benjaminshafii wants to merge 2 commits into
devfrom
feat/gmail-draft-file-inputs
Closed

benjaminshafii wants to merge 2 commits into
devfrom
feat/gmail-draft-file-inputs

Conversation

@benjaminshafii

Copy link
Copy Markdown
Member

Problem

An agent asked to email a workspace file reported: "The Gmail capability can't add attachments... no such capability exists on this connection." Attachments were not gone — #3458 correctly moved bytes off model context — but the replacement lived on a separate local extension action that cloud search_capabilities can never return, and the one sentence pointing to it (the route description) was stripped from /mcp/agent search results. A capability split patched over with prose is not discoverable by construction.

Standard practice

This is the exact problem the MCP File Uploads Working Group exists for. Its charter names the anti-pattern we had ("servers resort to prose instructions asking for base64 strings or local paths") and anchors on SEP-2356: declarative file inputs — file inputs are declared on the tool's input schema via an x-mcp-file descriptor (accept/maxSize), the host fulfills the file slot (the model passes paths/references, never bytes), and large files route through URL-mode elicitation (SEP-1036, Final). Prior art: OpenAI Apps SDK openai/fileParams.

Design

One capability, intent-shaped schema; transport is plumbing.

  1. gmail-drafts declares the file input (ee/apps/den-api/src/routes/org/google-workspace.ts): attachments — workspace file paths, annotated x-mcp-file: { maxSize: 4 MiB, maxFiles: 10 }. The schema rides along in every search_capabilities match (bodySchema), so discovery is data, not steering. Summary no longer says "without attachments".
  2. Cloud route never touches bytes: if attachments reaches the JSON route, it creates nothing and answers 422 file_input_requires_host with a machine-readable descriptor: { field, extensionId, action, argsField }.
  3. Host fulfillment, generic (apps/server/src/opencode-plugins/openwork-extensions-preview-file-inputs.ts): a tool.execute.after hook on openwork-cloud_execute_capability spots that error, re-runs the request through the descriptor's local action — the existing openwork-cloud-uploads authenticated multipart lane (authorized-roots + 4 MiB enforcement unchanged) — and rewrites the tool result in place. The model sees one capability and one successful call.
  4. Search results keep agent guidance (ee/apps/den-api/src/mcp/search.ts, native-capabilities.ts, agent.ts): matches now carry the route description and score against it; /mcp/agent no longer drops text written specifically for agents.

Degradation is honest: hosts without the hook (old desktop, Cursor/Claude Code on /mcp/agent) get the 422 with explicit next steps. Drive upload and any future file-carrying capability reuse the same descriptor + hook with zero new code paths. When SEP-2356 ratifies, the schema surface is already conformant.

Tests

Commands run locally (macOS, worktree off origin/dev):

  • apps/server: bun test src/opencode-plugins/openwork-extensions-preview-file-inputs.test.ts src/extensions/cloud-uploads.test.ts src/extensions-connect-gating.test.ts — 18 pass / 0 fail (3 consecutive runs); bun test src/opencode-plugins/openwork-extensions-preview.test.ts src/opencode-plugins/openwork-extensions-preview-connect-steering.test.ts — 32 pass / 0 fail; pnpm --filter openwork-server typecheck — clean; pnpm --filter openwork-server build — bundles the new hook into dist/opencode-plugins/openwork-extensions-preview.js.
  • ee/apps/den-api: pnpm exec tsc -p tsconfig.json --noEmit — clean; bun test test/gmail-draft.test.ts test/mcp-catalog-parameter-refs.test.ts — 18 pass / 0 fail; direct check that x-mcp-file survives hono-openapi resolution and that search_capabilities("gmail draft with attachments") returns the capability with description + descriptor.
  • Not runnable locally (needs seeded den DB; fails identically on clean origin/dev): test/google-workspace-capabilities.test.ts — extended with a 422 file_input_requires_host route test (asserts googleCallCount === 0) and discoverability assertions for the new summary/description/x-mcp-file.

Verification status

Incomplete — runtime-observable change; no @openwork/testkit tape yet. The end-to-end claim ("agent asks to email a file → one tool call → draft with attachment, bytes outside model context") needs an evals/specs/*.slow.test.ts against a Gmail witness plus the DB-backed den suite in CI/Daytona. Repro for the core loop without the app: run the den 422 test against a seeded den, then feed its response through repairFileInputToolResult (covered by the new unit tests).

…ttachments

Agents could not attach files to Gmail drafts: attachments lived on a
separate local extension action invisible to cloud capability search, so
sessions concluded attachments were impossible (looked like a regression
of #3458; it was a discoverability split).

Standard-shaped fix (MCP SEP-2356 declarative file inputs):
- gmail-drafts bodySchema gains attachments: workspace file paths
  annotated with an x-mcp-file descriptor. The schema is the discovery
  surface; no steering prose.
- If paths reach the cloud JSON route, it creates nothing and answers
  422 file_input_requires_host with a descriptor naming the local
  extension action that owns the byte transport.
- The desktop plugin fulfills it in a generic tool.execute.after hook:
  re-runs the request through openwork-cloud-uploads (the existing
  authenticated multipart lane) and rewrites the tool result in place.
  One capability, one successful call; bytes never transit model context.
- search_capabilities matches now carry the route description and score
  against it, so guidance written for agents is no longer dropped on
  /mcp/agent.

Hosts without the plugin (or old builds) get the honest 422 with next
steps instead of silent failure. Drive and future file-carrying
capabilities can reuse the same descriptor + hook unchanged.
@vercel

vercel Bot commented Aug 10, 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 5, 2026 7:56pm UTC
openwork-den Ready Ready Preview Sep 5, 2026 7:56pm UTC
openwork-den-worker-proxy Ready Ready Preview Sep 5, 2026 7:56pm UTC
openwork-landing Ready Ready Preview, v0 Sep 5, 2026 7:56pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
openwork-diagnostics Skipped Skipped Sep 5, 2026 7:56pm UTC

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Deploying openwork with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5c4eb75
Status: ✅  Deploy successful!
Preview URL: https://0605983e.openwork.pages.dev
Branch Preview URL: https://feat-gmail-draft-file-inputs.openwork.pages.dev

View logs

@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Deployment failed for project openwork-app with the following error:

Too many requests - try again in 5 minutes (more than 120, code: "api-deployments-flood-pro").

Learn More: https://vercel.com/docs/limits#rate-limits

@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics September 5, 2026 19:56 Inactive
@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Deployment failed for project openwork-landing with the following error:

Too many requests - try again in 5 minutes (more than 120, code: "api-deployments-flood-pro").

Learn More: https://vercel.com/docs/limits#rate-limits

@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Deployment failed for project openwork-den with the following error:

Too many requests - try again in 5 minutes (more than 120, code: "api-deployments-flood-pro").

Learn More: https://vercel.com/docs/limits#rate-limits

@reachjalil

Copy link
Copy Markdown
Member

Superseded by #4685: the existing Gmail draft capability now advertises workspace attachments, with fixed host fulfillment, selected-connection preservation, cancellation handling, and published exact-head boundary proof. Closing this proposal in favor of the clean replacement.

@reachjalil reachjalil closed this Sep 9, 2026

This branch was previously deployed

1 inactive deployment
Preview – openwork-diagnostics — 5c4eb756 Deployed Sep 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants