Skip to content

Agent uploads: a guide for operators and agent builders

An agent that has a file on disk and a shell can add it to a site’s media library without sending the bytes through the conversation:

  1. create_upload declares the file: its exact size, type and SHA-256, plus the alt text and other fields the asset should get. The answer is a short-lived PUT link and a ready curl line.
  2. The agent’s shell PUTs the file to that link.
  3. complete_upload turns the received bytes into an asset, which answers as upload_asset does.

upload_asset (base64, at most 4 MB) stays for small files and for agents without a shell. The design and its reasons are in RFC-0048 and ADR-0048.

  • One file. The link is bound to the site, the upload, the method (PUT), the exact size, the declared type and the exact SHA-256. Anyone who holds the link can upload only that file, and needs its bytes to do so.
  • Once. A second PUT answers 410 upload_used. A PUT the server refuses (wrong size, type or hash) can be repeated with the right file, up to three attempts in all.
  • For a short time. The PUT must start within 10 minutes of create_upload. The received bytes must be completed within 60 minutes. After that they are collected like any unused file, 24 hours later.
  • Nothing else. The PUT never creates, changes or publishes anything. The asset is created only by complete_upload, under the same key, scope (asset:upload), mode, approval, daily limit and site quota as upload_asset. In manual mode a person approves the file once, at create_upload. The prompt names its size, type and the start of its SHA-256.

For agents and agent builders

Hash the file first:

System Command
macOS shasum -a 256 photo.webp
Linux sha256sum photo.webp
PowerShell Get-FileHash -Algorithm SHA256 photo.webp

Then call create_upload with bytes (the file’s size in bytes), mediaType and sha256. Run the curl line it returns, with the file’s path in place of its name:

Terminal window
curl --fail-with-body -X PUT -H 'content-type: image/webp' --upload-file ./photo.webp 'https://studio.example.com/api/sites/site_…/assets/agent-uploads/upl_…?sig=…'

Finally call complete_upload with the uploadId. If the library already holds the same bytes, create_upload answers status: "existing" with that asset and no link, so there is nothing to send.

  • Check first. get_mode → uploads says whether this server hands out links (signedUrl), the cap per file (maxBytes) and how long a link lasts (linkSeconds).
  • Keep the link private. Treat the link like a password for that one file: do not paste it into chats, tickets or logs. A leaked, unused link lets someone else burn its three attempts; the agent then calls create_upload again.
  • Refusals carry a details.reason and the next step: upload_cap, unsupported_type, too_many_uploads, upload_pending, upload_failed, upload_expired and signed_upload_unsupported, among others.

For operators

Settings

Where Setting Default
cloudhal.json "media": { "agentUploads": false } turns links off on
cloudhal.json "media": { "agentUploadBytes": 52428800 } sets the cap per file, at most 100 MB and each type’s own cap 25 MB
self-host CLOUDHAL_AGENT_UPLOADS=off, CLOUDHAL_AGENT_UPLOAD_BYTES=<bytes> on, 25 MB
both at most 10 open uploads per agent key and 50 per site; per key per 24 hours, 100 files and 500 MB (open uploads count) fixed

cloudhal deploy writes the cloudhal.json settings into the admin Worker’s vars (CLOUDHAL_AGENT_UPLOADS, CLOUDHAL_AGENT_UPLOAD_BYTES). cloudhal studio reads them from the project. Stdio cloudhal mcp never hands out links: it has no HTTP listener for the PUT.

The signing secret

Links are signed with HMAC-SHA-256 under CLOUDHAL_UPLOAD_SECRET (at least 32 characters). When it is not set, the preview secret is used instead, then the MCP state key.

  • Cloudflare. cloudhal deploy generates the secret once into .cloudhal/deploy/secrets.json (mode 0600; never commit it) and gives it to the admin Worker as a secret. It is never printed or written into a config. Older deployments get it on their next deploy.
  • Self-host. It is optional. cloudhal selfhost secrets generates it for new installations. Existing ones may add CLOUDHAL_UPLOAD_SECRET or CLOUDHAL_UPLOAD_SECRET_FILE (Docker and Kubernetes secrets), or leave it unset and keep using the preview secret. A value shorter than 32 characters stops the image at start with a message.
  • Rotation. Change the secret and redeploy (or restart). The only casualty is links that were not used yet: they answer 403 bad_signature, and the agent calls create_upload again. Bytes that were already received stay completable.

Logs: keep the query string out

The link’s credential is its ?sig= query parameter.

  • Cloudflare. Workers Logs and traces drop query strings (redact_query_string, set by cloudhal deploy).
  • Cloudhal itself. It logs no request URLs, and its audit rows never hold the link.
  • Anything you put in front of Cloudhal can still log it:
    • Reverse proxies and ingress controllers log the full request line by default. That includes ingress-nginx, nginx, Traefik, Envoy-based gateways, HAProxy, and load balancers’ access logs. Strip the query string from their access log format (for nginx, log $uri instead of $request or $request_uri), or exclude the path /api/sites/*/assets/agent-uploads/* from access logs. The caddy profile of the compose file configures no access log.
    • wrangler tail streams live requests to whoever runs it. Whether redact_query_string applies to tail sessions is not verified. Treat a tail session’s output as containing links, and do not paste it anywhere.
    • CI logs and shell history of the agent’s machine hold the curl line. Links expire within 10 minutes and work once, but keep such logs private.

Body size limits

The PUT goes through the admin Worker (Cloudflare and self-host alike) to the media store, which stays private.

  • Cloudflare. Request bodies are limited by the zone’s plan: 100 MB on Free and Pro, 200 MB on Business (Workers limits).
  • Self-host. A reverse proxy in front must accept bodies up to the agent cap. Many default to 1 MB (nginx client_max_body_size, ingress-nginx nginx.ingress.kubernetes.io/proxy-body-size).

Turning it off

Set "media": { "agentUploads": false } and deploy again (self-host: CLOUDHAL_AGENT_UPLOADS=off and restart). create_upload then answers signed_upload_unsupported, and agents fall back to upload_asset. Open uploads expire within the hour, and bytes already received are either completed or collected.