Repository navigation
Description
Summary
Public-channel agents (Telegram, Slack, public links) silently cannot read images today, even when file upload Phase 2 (#487/#494) successfully delivers them to the workspace. Agent owners need a per-agent, configurable file-exchange policy that decides which file types the agent is allowed to consume from public channels — including images.
Component
Backend / adapters/message_router.py, agent configuration (agent_ownership), Settings/Agent UI
Current Behavior
When a Telegram (or other public-channel) user sends a photo:
telegram_adapter._extract_files()parsesphoto[]/documentcorrectly._handle_file_uploads()downloads via TelegramgetFileand writes the bytes into the agent's per-session upload dir.- The agent prompt gets a
[User sent a photo: <caption>]description line. - However, the agent's tool list stays at the public default (e.g.
WebSearch, WebFetch) —Readis deliberately not added for image MIMEs, so the agent cannot inspect the file it just received.
Source: src/backend/adapters/message_router.py:507-518
# Images are excluded: Claude Code crashes when reading PNGs with
# --allowedTools (API returns 400 "Could not process image" and the
# process exits without flushing stdout, hanging the pipe reader).
_IMAGE_MIMES = {"image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"}
has_readable_files = message.files and any(
f.mimetype not in _IMAGE_MIMES for f in message.files
)
if has_readable_files and "Read" not in public_allowed_tools:
public_allowed_tools = public_allowed_tools + ["Read"]The exclusion is a fleet-wide hard-coded workaround for an upstream Claude Code stdio bug. There is no opt-in, no per-agent override, and no UI surface that signals to operators "your public-channel users can send pictures, but I can't look at them."
Why It Matters
- File upload Phase 2 just shipped, so users will increasingly attach photos/files when chatting with public agents and reasonably expect the agent to "see" them.
- Some agent use cases (vision-capable assistants, document Q&A, OCR helpers) are useless without image read access from public channels.
- Some operators want the opposite — strict no-file-Read for compliance — and that should also be expressible.
- The current code path silently drops the capability with no log line at WARN/INFO that an image was excluded from
Read, making the failure mode invisible to operators.
Proposed Design
1. Per-agent config
Add a public_channel_file_policy JSON column on agent_ownership (or extend guardrails_config) with a shape like:
{
"allow_image_read": false,
"allow_document_read": true,
"max_file_size_mb": 10,
"allowed_mime_prefixes": ["image/", "application/pdf", "text/"]
}Defaults preserve current behavior (image read off, document read on).
2. Router consults config
message_router.py reads the agent's policy and decides whether to add Read for image MIMEs. When allow_image_read=true is enabled but the upstream Claude Code stdio bug still applies, the router should either:
- Inline images directly into the prompt as base64 vision content (Sonnet/Opus support this natively, no
Readtool needed), or - Add
Readand log a clear WARN when the workaround is bypassed.
The first option is preferred — it sidesteps the Claude Code --allowedTools crash entirely by using the model's native vision capability.
3. UI surface
Agent Detail → Settings → "Public channel file exchange":
- Toggle: "Allow image reading from public channels"
- Toggle: "Allow document reading from public channels"
- (Optional) per-MIME allow-list, max file size
4. Observability
Emit an INFO log when a file is accepted into the workspace AND a WARN when a file is dropped/excluded by policy, including the MIME type and reason. Today the path is silent on the exclusion.
Acceptance Criteria
- Per-agent file-exchange policy persisted in DB
- API endpoints to read/update the policy (admin/owner only)
- UI toggle on Agent Detail
-
message_router._handle_file_uploadsconsults policy - Image route either inlines via vision content blocks OR adds
Readbased on policy - WARN log when a file is excluded by policy
- Defaults match today's behavior (zero migration impact)
- Documented in feature flow
telegram-integration.mdand access-control docs
Related
- feat(telegram): Phase 2 — deliver uploaded files to agent workspace (#354 follow-up) #487 / feat(channels): file upload Phase 2 — workspace delivery hardening (#487) #494 — file upload Phase 2 (workspace delivery hardening)
- feat: File upload support for external channels (Telegram, Slack, public links) #354 — file upload Phase 1
- feat: Unified channel access control — verified-email identity, per-agent allow-list, access requests (web / Telegram / Slack) #311 — unified cross-channel access control
- GUARD-001 — per-agent guardrails (natural place to host this)
src/backend/adapters/message_router.py:507-518src/backend/adapters/telegram_adapter.py:_extract_files
Activity