Skip to content

fix(gateway): translate Docker container paths to host for MEDIA delivery (#66086, #42299) - #81746

Merged
teknium1 merged 2 commits into
mainfrom
fix/66086-outbound-media-translation
Aug 8, 2026
Merged

fix(gateway): translate Docker container paths to host for MEDIA delivery (#66086, #42299)#81746
teknium1 merged 2 commits into
mainfrom
fix/66086-outbound-media-translation

Conversation

@teknium1

@teknium1 teknium1 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Outbound MEDIA delivery now translates Docker container paths to their host equivalents before validation, so an agent writing /workspace/chart.png, /output/report.pdf, or /root/out.png inside the sandbox gets its attachment delivered instead of silently dropped. Fixes #66086 and #42299 — the outbound inverse of the inbound file-visibility class closed in #80801/#81200/#81677/#81717.

Root cause: MEDIA delivery runs in the host gateway process, where container-absolute paths fail resolve(strict=True) in validate_media_delivery_path and the attachment vanishes with no error.

Changes

Salvaged from #37207 (@charzhou, authorship preserved) — the cleanest of a 4-PR cluster (#27779, #42305, #47716 same idea):

  • _translate_docker_container_media_path(): longest-prefix match across configured docker_volumes (named volumes skipped) plus a synthetic /workspace mount for the default persistent sandbox / cwd bind; containment check after resolve.

Our follow-up commit widens it to the full mount surface:

  1. Persistent /root home mount<sandbox>/docker/default/home is a real bind mount; /root/out.png now delivers.
  2. Hermes cache mountsMEDIA:/root/.hermes/cache/images/… (the agent_visible_image path the agent legitimately sees under docker) translates to the HOST cache file via longest-prefix.
  3. Credential fail-closed/root/.hermes/* outside a cache mount (the sandbox's .env/auth.json copies, which live outside the host denylist prefixes) never translates through the home mount.
  4. In-process gateways — runs the idempotent terminal-config→env bridge before mount parsing, so Desktop-backend/hermes serve gateways see terminal.backend/docker_volumes without a launcher bridge.

Validation

MEDIA path Before After
/workspace/chart.png dropped delivered (host sandbox workspace)
/output/report.pdf (docker_volumes) dropped delivered (#42299)
/root/out.png dropped delivered (persistent home)
/root/.hermes/cache/images/gen.png dropped delivered (host cache)
/root/.hermes/auth.json rejected (fail-closed)
nonexistent container path rejected rejected

test_platform_base.py + test_send_image_file.py — 94/94 (5 salvaged tests + 3 new). Ruff clean. E2E: all six scenarios above verified against the real validate_media_delivery_path in an isolated HERMES_HOME.

Infographic

Sandbox files find their way home

charzhou and others added 2 commits August 8, 2026 05:53
Translate MEDIA paths under configured Docker volume mounts (and the
default persistent /workspace) to host paths before media delivery
validation, using longest container-prefix match so host:/workspace and
/output export mounts work.
… and in-process gateways

Follow-ups on the salvaged commit (#37207 by @charzhou):

- Persistent /root home mount translates too: an agent writing
  /root/out.png produced a real host file under
  <sandbox>/docker/default/home the gateway could not find.
- /root/.hermes cache mounts translate to the HOST cache (longest-prefix
  beats the home mount), so MEDIA:<agent_visible_image> paths deliver.
- /root/.hermes/* OUTSIDE a cache mount never translates through the home
  mount: those are the sandbox's credential copies (.env, auth.json) that
  sit outside the host-side denylist prefixes — fail closed.
- Run the idempotent terminal-config->env bridge before mount parsing so
  in-process gateways (Desktop backend, hermes serve) see the active
  backend and docker_volumes (covers #42299's /output case there too).
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 78a0deb

⚠️ Warnings

OSV vulnerability scan · View job

56 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 3m40s vs 7m15s (-49.4%). 12 job(s) slower, 9 faster, 2 unchanged.

  • Python tests / Run tests slice 11/12: +25.0s
  • Python tests / Run tests slice 4/12: -18.0s
  • Python tests / Run tests slice 8/12: +10.0s
  • OSV scan / Scan lockfiles / osv-scan: +7.0s
  • Python tests / Run tests slice 3/12: -6.0s

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery backend/docker Docker container execution sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Aug 8, 2026
@teknium1
teknium1 merged commit 238351a into main Aug 8, 2026
47 checks passed
@teknium1
teknium1 deleted the fix/66086-outbound-media-translation branch August 8, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/docker Docker container execution comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Docker-backed gateway silently drops MEDIA attachments for container-local /workspace paths

3 participants