← Back to Pull requests

Attachments: send files up to 100 MB over the gateway's file upload #347

Closed
unknown closed this pull request without merging on Nov 02, 2026 23:16 UTC
View on GitHub
unknown unknown commented on Nov 02, 2026 21:37 UTC
Author

Stacked on #346. Review that one first; this PR's diff is only the last four commits.

What and why

#346 holds attachments to 12 MB, which is what one WebSocket message carries. This PR raises the limit to 100 MB, which is what the gateway's managed-file upload takes. Files up to 12 MB still go inline, as before.

  • Upload. A file over 12 MB streams up over HTTP into a folder of its own, <files root>/.kyllene-uploads/<random>/<name>. It's read as it goes, so it's never held whole in memory. On Android that means streaming from the picked URI. A file whose size the provider doesn't report is copied to the cache first.

  • Attach. The file is then attached by its path on the gateway. A PDF up to 50 MiB gives its pages through pdf.attach. Anything else, or a PDF the gateway can't render, becomes an @file: reference through file.attach.

  • Cleanup. The upload is removed once it's attached. The exception is when file.attach uses it in place (uploaded: false, meaning the chat's workspace contains the uploads folder), because the prompt refers to it. Those are cleared after a week, as the gateway does with its own staged uploads. A failed upload is also removed.

  • Progress. "Uploading <name> · N%" shows under the pending bubble. A 60 MB file over a slow link takes minutes, and before this the bubble just looked stuck.

  • Sends wait for each other. Without this, a second prompt sent during a long upload would carry off the images the first one had already queued on the session.

  • Older gateways. A gateway without the upload route, or one that answers the listing with a web page, gets: "<name> is larger than 12 MB, the most this gateway takes. Update Hermes to send files up to 100 MB."
  • Follows up #340.

    Gateway

    The calls follow hermes-agent:

  • GET /api/files gives the default files folder. With ?path= it lists the uploads folder, which is how old uploads are found to clear.

  • POST /api/files/upload-stream takes the multipart fields file, path and overwrite. It's capped at 100 MiB, and parent folders are created. Source: hermes_cli/web_routers/files.py.

  • DELETE /api/files takes {path, recursive}.

  • pdf.attach {session_id, path, filename} and file.attach {session_id, path, name} are in tui_gateway/methods_prompt.py. The in-place rule and the uploaded flag are in tui_gateway/prompt_attachments.py.
  • The managed-file routes exist since v2026.7.1. On an older gateway, a 404 or 405 (or a non-JSON listing) gives the update message, and files up to 12 MB work as before. POST /api/chat/file-upload wasn't usable here: it's capped at 16 MiB and only runs on the web app's listener.

    How I tested it

  • Tests added:

  • - ChatSessionTest, with MockEngine for the file routes and FakeTransport for JSON-RPC:
    - a large PDF goes up and is attached by its path
    - a 30 MB file is streamed byte for byte, and its progress goes from 0 to 100%
    - a file used in place stays
    - a PDF the gateway can't render goes as a file
    - a gateway without the route, or one that answers with its web page, gets the update message
    - a failure after the upload removes it and takes back the queued images
    - a refused upload is removed
    - a file that changes while it's sent is turned down
    - a Windows gateway gets backslash paths
    - uploads older than a week are cleared, once per run
    - a second send waits for the first one's upload
    - AttachmentUploadsTest: file names (folders, .., $VAR/%VAR%, trailing dots and spaces, Windows device names).
    - ChatViewModelTest: the 100 MB limit.
  • On a device (emulator, against a v0.22.5 Docker gateway):

  • - a 12.8 MB PDF arrived, and the agent read back 12,806,962 bytes
    - a 60 MB file arrived (60,000,000 bytes), with the app's heap around 31 MB during the upload
    - the progress line went from 6% to 100% over about two minutes on the emulator's link, then went away

    Screenshots

    The pending bubble while a 60 MB file goes up:

    Checklist

  • One feature or fix, and its ROADMAP item is ticked

  • Up to date with master, and the command under "Tests" in CONTRIBUTING.md passes

  • A late answer after a profile, gateway or chat switch is dropped; reconnect, rotation and a second tap work

  • Anything cached or stored is keyed by gateway and profile

  • Tested with unusual text, if it shows replies or other gateway text: code fences, very long words, CRLF, empty values

  • No tokens in URLs, and no fetches of an address on the user's own network that a reply or page links to

  • Reuses the app's components, fits at 360 dp in both themes, and icon buttons have content descriptions

  • The desktop app builds (./gradlew :desktopApp:compileKotlinJvm)

  • "Allow edits by maintainers" is on
  • !A pending prompt showing Uploading logs-60mb.bin · 6%

    Diff: 617 lines (+462 / -155) across 7 files Reviewer: Giton22 Review duration: 99m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 617 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.384
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #347"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.2% (MEDIUM) · Higher = larger blast radius
    50.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.8% · Safe to merge
    19.8%