Skip to content

feat: configurable file/image exchange policy for public-channel agents #499

Open

Description

@vybe

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:

  1. telegram_adapter._extract_files() parses photo[] / document correctly.
  2. _handle_file_uploads() downloads via Telegram getFile and writes the bytes into the agent's per-session upload dir.
  3. The agent prompt gets a [User sent a photo: <caption>] description line.
  4. However, the agent's tool list stays at the public default (e.g. WebSearch, WebFetch) — Read is 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 Read tool needed), or
  • Add Read and 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_uploads consults policy
  • Image route either inlines via vision content blocks OR adds Read based 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.md and access-control docs

Related

Activity

  1. added
    complexity-low
    theme-channels
    on Jun 3, 2026
  2. added
    status-incubating
    and removed on Jun 14, 2026
  3. added
    complexity-medium
    and removed
    complexity-low
    on Sep 2, 2026
  4. added
    status-ready
    and removed
    status-incubating
    on Sep 24, 2026
  5. added
    status-in-progress
    and removed
    status-ready
    on Oct 17, 2026
  6. added
    status-ready
    and removed
    status-in-progress
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p2status-readytheme-channelstype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions