Repository navigation
feat(den-api): convert Office uploads to native Google Docs, and stop advertising an impossible inline base64 limit - #3327
benjaminshafii wants to merge 2 commits into
Conversation
… advertising an impossible inline base64 limit
The Drive upload capability built its multipart metadata as { name, parents }
with no mimeType, so an uploaded .docx could only ever land in Drive as a
.docx. There was no way to get a native, editable, commentable Google Doc.
Add an optional convertTo (document | spreadsheet | presentation) that sets
the metadata mimeType to the target Google editor type while the media part
keeps the caller's source mimeType, which is the mechanism Drive uses to
convert. Omitting convertTo is byte-identical to today.
Separately, the dataBase64 descriptions instructed agents to "read the file
from the active workspace and base64-encode it" alongside an advertised
10 MiB ceiling. That ceiling is real server-side but unreachable in practice:
the base64 has to be emitted by the model as a tool-call argument, so it is
bounded by the model's output budget and fails well below 10 MiB, before any
request is sent. Reword both descriptions to state the practical inline limit
and keep the 10 MiB figure labelled as a server ceiling.
Path- or URL-based upload, so bytes never transit model context, is the real
fix for large files and is left to a follow-up.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Thanks for digging into this and for identifying the base64/tool-call limitation. My product preference is that OpenWork preserve users’ files exactly as supplied rather than converting Office files on their behalf—or allowing the agent to choose a conversion implicitly. If someone uploads a I’m addressing the underlying upload/download transport separately with a byte-outside-model architecture: scoped, expiring file references; multipart Google Drive uploads for small files; resumable uploads for larger files; and download materialization without returning file bytes through model context. Given that direction, I recommend that we do not merge the |
Deploying openwork with
|
| Latest commit: |
79e2ff2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://40944896.openwork.pages.dev |
| Branch Preview URL: | https://fix-drive-upload-google-docs.openwork.pages.dev |
|
Deployment failed for project openwork-diagnostics with the following error: Learn More: https://vercel.com/docs/limits#rate-limits |
|
Deployment failed for project openwork-landing with the following error: Learn More: https://vercel.com/docs/limits#rate-limits |
|
closed due to age, please reopen and tag me if still valid |
Why
Two separate defects, found while trying to get a
.docxagreement into Drive as an editable Google Doc.1. The Drive upload capability cannot produce a Google Doc.
POST /v1/capabilities/google-workspace/drive-filesbuilt its multipart metadata as{ name, parents }with nomimeType, so an uploaded.docxcould only ever land as a.docx. There was no path to a native, editable, commentable Google Doc — which is what you actually want for anything that needs redlines.2. The
dataBase64descriptions instruct an operation that cannot succeed. The schema told agents to "Read the file from the active workspace and base64-encode it" and advertisedmaxLength: 13981016(10 MiB).That 10 MiB ceiling is real server-side but unreachable in practice. I audited every hop and there is no byte limit anywhere in our code:
execute_capabilityinputSchema.bodyz.unknown()(mcp/agent.ts:517)normalizeToolBody→JSON.stringify→app.fetchmcp/invoke.ts:29,97,132) — in-process, never crosses a socketbodyLimit@hono/mcptransportuploadDriveFileBodySchemaThe actual ceiling is the model's tool-call output budget: the base64 must be emitted by the model as a JSON string argument. A ~137KB payload (a small
.docx) truncated mid-generation and arrived as{}— no server error, because the request never became a well-formed tool call. So we were advertising ~100× more headroom than is reachable, and telling agents to walk straight into it.What changed
convertTo(document|spreadsheet|presentation), optional. Sets the metadata mimeType to the target Google editor type while the media part keeps the caller's source mimeType — the documented Drive conversion mechanism..docx→Doc,.xlsx→Sheet,.pptx→Slides.convertTois byte-identical to today (nomimeTypekey emitted at all). Pinned by the pre-existing test, which asserts the exact metadata JSON{"name":"plan.pdf","parents":["folder_1"]}.dataBase64descriptions to state the practical inline limit and keep 10 MiB labelled as a server ceiling, not a usable one.evals/flows/google-workspace-gmail-draft-attachments.flow.mjs:77, which asserted the old wording verbatim.No validation limits changed. Change 2 is descriptions only.
Tests
Three new tests: conversion sets the right metadata mimeType and preserves the source media mimeType; invalid
convertTo400s without calling Google; the existing omission test is unchanged and still passes.Validation honesty
Per AGENTS.md: there is no live Drive proof in this PR, and I want to be explicit about that. Verifying an actual
.docx→Google Doc conversion requires a connected Google Workspace account hitting real Drive, against a deployed den-api carrying this change. I ran the unit suite against the fake Google, which asserts the exact multipart bytes we send — that proves we send the documented conversion request, not that Google converts it.Reviewer check: upload a
.docxwithconvertTo: "document"and confirmfile.mimeTypecomes back asapplication/vnd.google-apps.documentandwebViewLinkopens in the Docs editor.Deliberately not in this PR
apps/server/src/extensions/google-workspace.ts:91-104(takesattachments: [{ path }], server reads the bytes at:759), but it has no Drive equivalent and is gated off for Cloud users (extensions/index.ts:61-72). Closing that gap spansapps/server↔den-api auth, or needs server-side URL fetching with real SSRF hardening. That's a design decision, not a patch.packages/docs/openapi.json. It is already stale ondev. Regenerating it pulls in ~230 unrelated keys (cloud gateway routes,/v1/org.delete, install-connect, marketplace-capabilities) and 7 unrelated description edits. That belongs in its own chore PR. The runtime path reads live-generated OpenAPI (mcp/catalog.ts), so this change takes effect regardless.gmail-attachmentreturns up to 10 MiB of base64 into model context (google-workspace.ts:553) and will fail the same way on large attachments.