Files
slacker-bot/plan/send-files-to-user.md
T

2.2 KiB

Agent sends files to the user

Give the agent a send_file tool, so it can hand back images, videos, PDFs, archives or any other file it made. The bot uploads the file into the session's thread, where Slack previews images, video and PDFs inline.

Shape

  1. The tool runs inside the container. It's a tiny stdio MCP server added to nix/container.nix (for example slackerbot-tools). The bot passes it to goose in session/new and session/load through mcpServers (now [] in acp.go), so every session gets it without a goose config change.
    • send_file(path, comment?): checks that the path is a regular file under /root and below the size cap, then returns "queued". It doesn't move any bytes itself, so file contents never land in the model's context.
    • Check first that the goose serve version we ship honours mcpServers from ACP. If it doesn't, register the extension in goose's config in container.nix instead.
  2. The bot does the upload. The streamer already sees ACP tool_call / tool_call_update messages. When a send_file call completes, the bot reads rawInput.path, fetches the file from the container's home, and calls files.uploadV2 (files:write) into the thread, with comment as the initial message.
  3. Getting the bytes from the home needs a new node operation, read_file(machine, path), that streams the file in chunks the same way export_home / read_export do.
    • local opens the file with os.OpenInRoot(home, rel) (Go 1.24), so symlinks and .. can't escape the home.
    • It's a new call name in manager/cluster.go. Old slaves answer "unknown call", and the bot replies "This node is too old to send files" instead of failing the turn.
    • Files go node → master → Slack, so slaves still need no Slack token.

Limits and config

  • max_send_file_mb in config.toml (default 100). Slack's own limit is 1 GB.
  • At most a few files per turn, so a looping agent can't flood a thread.
  • The tool's description tells the agent to use it for anything the user should see or download, rather than pasting long output.

Docs to update when built

USERGUIDE (agent can send files), ARCHITECTURE (read_file call, MCP tool), INSTALLATION and config.example.toml (max_send_file_mb).