OpenProgram Docs

Chat attachments

One text marker carries every file in a message:

[attachment: notes.txt (txt, 18 KB, 4210 lines) @json "/abs/path/notes.txt"]

Written only by format_marker in openprogram/state/attachments.py; a fifth source calls it too. Read on the web only by parseAttachments. An optional @previewjson names a saved preview. The older @ /abs/path spelling stays readable. How content enters model context: Attachment handling.

Inbound

SourceBytesModel inputChat
Web image: paste, drag, pickerSession workdir attachments/, SHA-256 dedup in the session, 32 MB per file, 64 MB per turnImage content and pathThumbnail chip, click for full size
Web document: PDF, code, binarySame store; local files can stay at their pathPath; tools read on demandClickable chip, overlay viewer
@mention, entered pathUnchanged location, zero copyPathClickable chip
Telegram, Discord, Slack, WeChat<state>/channels/<channel>/accounts/<account>/attachments/, 20 MB, no dedupImages up to 4 MB as image content, others as pathThumbnail chip, marker hidden

Channel text is prefixed with [display name (id)] and markers follow. _one_line removes brackets from the name so a prefix cannot be forged. Unnamed pasted images get an extension from their media type.

In a message

WhereHow
User messages, message railAttachmentChips; AttachmentPreview opens an overlay around FileViewer's absolute-path mode, so the reading position stays
Assistant repliesAssistantFileCards, same markers; opens in a center file tab
Just sentchat_ack echoes the stored text, so a new attachment is clickable at once

Reply file cards

File attached to a replyPreview
Image, video, audioShown or played in place
PDFFirst page, cut to a 16:9 frame
Word, PowerPoint, ExcelFirst page as the worker draws it (/api/file-thumbnail): macOS Quick Look, else the picture the authoring app saved in the file; cut to a 16:9 frame. Neither: name row only. The in-app editor is an optional 730 MB install, too heavy to boot per card
HTMLDrawn at 1280 × 720, scaled into a 16:9 frame
zip, tarFirst level, with a file count per folder
TextOpening lines

Every card with a preview is a third of the text column (240–440 px), three to a row: enough to tell files apart, and the full view is one click away. A card with no preview is a name row on its own line.

A card is drawn only for an attachment the server put on the message: a send_file file or a file the turn produced. The browser derives no card of its own.

When the turn's final text is assembled (with_attachments), a marker the model typed for a file the turn did not record becomes the file's name, in the content and the text blocks: no card, path or automatic preview, live or after a reload. Upload and mention markers in the person's message stay.

  • A marker stays only when its path and any @previewjson path were both recorded.
  • The text a reply stores while streaming, kept by a reply a restart cut off, and an always-on report get the same treatment.
  • parseAttachments reads only the forms the server checks.

A script the reply links ([build.py](/abs/build.py)) or a file the agent only read stays a link in the prose (Paths in a reply).

When a reply finishes in the focused chat, its first attachment not already shown in the reply opens in the preview beside it: the deliverable the turn just made.

Below the preview: file-type icon, name, type and size (plus page or file count), then Open and Reveal in Finder (File Explorer, File Manager by platform). A file the app cannot show puts Download in the open slot; when the worker is not on the user's machine, the reveal slot downloads. Previews load as the card nears the screen.

HTML sandbox and archives
  • GET /api/file-page serves only .html and .htm, with sandbox allow-scripts and no allow-same-origin. A srcdoc frame would inherit the app's script-src 'self' and a script-drawn page would be blank.
  • The page has an opaque origin: no access to the app or its storage, its Origin: null requests are refused, it cannot navigate or open windows. Relative files are missing from the strip because the strict cookie is not sent; the page opened in a browser tab has them.
  • FileViewer sends a zip or tar to ArchivePreview: full tree on the left, the selected member on the right through the same FileViewer. Nothing is extracted to disk.

Paths in a reply

A file the reply only names, as `exports/plan.pptx` or [plan](/Users/me/exports/plan.pptx:3), is a link to that file. A click opens it in the preview beside the chat: an office file in the document editor, a PDF in the PDF viewer, a web page as a page.

StepRule
CandidatesInline code spans and markdown link targets of a settled reply (never code blocks, never while it streams). A path-shaped string: a folder separator or a name with an extension, absolute, ~ or relative; a :12 or #L12 suffix is dropped. Commands, web addresses and links to the app's own pages (/s/…, /settings) are not candidates
Confirmed by the workerGET /api/file-paths answers which candidates are files: absolute and ~ paths against readable_roots, relative ones joined to the chat's working directory first. Only confirmed paths become links, so a code span that looks like a name never turns into a dead link
CostThe candidates of every reply on screen go out in one request per chat (64 paths each, stat only), answers are kept five minutes (a missing file twenty seconds, since the agent may still make it). The text is drawn first and never waits
Not a routeA markdown link that can only be a local path (/… that is not an app page, ~/, ./, ../, file://, a drive) is stopped before the shell's router, which would take /Users/… for a page. Not confirmed yet, it is looked up on click; a file that is not there says so. A bare target (notes/plan.md, or docs.example.ai, a web address without its scheme) becomes a file link only once confirmed, and until then keeps its own click
Spaces in a pathA link to a root, ~/, file:// or drive path with a space in it ([deck](/Users/me/ICDM 2026/deck.pptx)) is still a link, though CommonMark ends a destination at a space and would print it as text. Models write paths this way. Web addresses keep the stock rule (lib/markdown/spaced-path-links.ts)
LookDrawn as the app's rendered-markdown links are (the file preview's): the link colour over a faint underline that turns solid on hover. A code span keeps its chip and takes the colour and the underline, so it is told apart from plain code at rest even where the link colour is close to the code colour. Only decoration changes, so the paragraph keeps its layout when a path becomes a link. Enter opens it

File menu

A right-click on a path in a reply, on a reply file card or on a row of the turn's changed files opens one menu, from FilePathMenuContent:

ItemWhat it does
Open previewThe click's action; left out on a card whose file nothing here can show
Copy ›Absolute path, Relative path (to the chat's project; disabled outside it), Filename
Reveal in FinderFile Explorer or File Manager by platform, through POST /api/file-reveal; only when the worker runs on this machine
Open in default appThe desktop app's files:open-default: the system opens the file as a double-click would, so a deck opens in Keynote or PowerPoint. Refuses a folder, an executable and anything the system would run (scripts, apps, installers, shortcuts). Absent in a browser or on another machine
Attach as contextAdds an @ mention of the file to the chat's message box

Right-click elsewhere in a reply keeps the browser's own menu, and a card inside a reply keeps its own. A deleted file in the changed-files card has no menu.

Outbound

send_file(path) resolve symlinks, check allowed roots, report; no delivery Turn end send_file calls and produced files, checked; markers to final_text Web file card under the reply Channel post_file, marker removed Fails: note with the path
  1. send_file(path)resolve symlinks, check allowed roots, report; no delivery
  2. Turn endrecorded send_file calls plus the files the turn produced, checked again, as markers on final_text
  3. Webfile card under the replyChannelpost_file, marker removed

    Fails: note with the path

AspectRule
Limit32 MB per file
ApprovalNone, in any mode. Attaching a file to the turn's own conversation is replying, so send_file is a no-decision tool (SAFE_TOOL) and needs fs.read, not network.send. Model review would judge an attachment a disclosure and refuse it, and after one refusal a model stops attaching for the rest of the chat. A paired chat-app speaker has no fs.read, so the owner's files are not sent to them
Files the turn producedAttached without a send_file call (see below)
Where the tool existsNot in cli, tui or plan (unsafe_in): the model cannot try and fail. Elsewhere it is a resident tool, a function of every request, never one to search for; a tool_search for it answers that it is already callable (Deferred tools)
What the prompt saysCall send_file for each deliverable when it is in the tools list, with no search first. Say that a file was not sent only when a send_file call refused it, with its reason, and never conclude it from a tool search. Not "never say it": the tool does refuse (a home file in a platform chat, a file over the limit), and hiding that leaves the user waiting for a file
PauseThe record is the source, so a resumed turn keeps its files
Refused pathAn error to the model that says the path is outside and names this conversation's own folders: its working folder, its project folder and its chat folder. Every other project's chats/ folder is also a root, but only counted ("40 other folders"), so the message stays short however many projects there are
BoundaryIn-process Python, outside openprogram/host/sandbox/, which governs shell commands. The path check is the whole boundary
Why a toolA MEDIA: line leaks to the user when extraction fails. A tool can report a missing file. Mentioning a path the turn did not modify sends nothing
Marker the turn did not attachNothing uploads. The channel checks the marker's path against the files the turn attached (its send_file calls and the files it produced), because a marker is text the model can also write. The turn's final text already reads such a marker as the file's name; one in text streamed before that becomes a Chinese note without the path
post_file not supported or failedThe marker becomes a Chinese note with the path, and failures are logged. Clickable links would need an externally reachable web URL

Files the turn produced

A model that builds a deck with a script and answers “done, it is at exports/plan.pptx” has attached nothing. At turn end, produced_files attaches such files itself, with the same marker, so the same card appears and a channel uploads them.

StepRule
CandidatesPaths the reply names: markdown link targets (also <…> and %20), code spans and bare tokens; absolute, ~, or relative to the project and then the session workdir; a :12 or #L12 suffix is dropped. Plus files write wrote and image_generate saved
Kept whenA regular file inside sendable_roots, at most 32 MB, modified at or after the turn started (one second of slack); a resumed turn uses its user message's time. Not a file the user sent in (workdir/attachments/, steer-images/): its mtime falls inside the turn too
FormatsOffice and other documents, PDF, images, audio, video, archives; and HTML, Markdown, CSV, TSV, SVG and notebooks unless the edit tools changed them, since the edit card already shows those with their diff. The rule is the same for every candidate, whether the reply named it or write or image_generate saved it, so the script that built a deck stays out. Source code and logs never, nor .key, which is also a private key's extension
LimitsAt most 64 candidates looked at with stat only, at most 8 attached, each once, after the send_file files. Any failure attaches nothing and never reaches the turn
WhereOnly where send_file exists (not cli or tui) and for a speaker with fs.read

The modification time is the guard: a file the model only read or mentioned is older than the turn and stays put.

The base guide asks the model to name each file it produced as a markdown link to its absolute path and to attach deliverables with send_file; the send_file description says it is for any file the user should see, office files a script made included.

File access

RootDisplayreadable_rootsSendsendable_roots
Conversation folders projects/*/chatsAllowedAllowed
Project bound to the sessionAllowedAllowed
OpenProgram checkoutAllowedRefused
Channel attachments foldersAllowedRefused
Folder of a chat with no project (the default project's, often home)Guarded, for that chatGuarded, while the chat stays in the App
Default project folder for any other requestRefusedRefused

resolve_within resolves symlinks before testing containment, so a link to ~/.ssh fails. Every session is auto-bound to the default project, so only non-default bindings count as a project. Channels are globbed down to the attachments leaf because credentials.json is a sibling.

A chat with no project

Such a chat works in the default project's folder, often the home directory, so a deck it builds lands there. That folder is a root only as a WorkdirRoot, for a conversation that exists and has no real project. A folder that is the filesystem root is never one, or the whole disk would be a root. The rules:

SurfaceRule
Preview, path links, file cards, reveal (readable_roots)Allowed for that chat's own requests. These are local to the owner's App
send_file and turn-end attach (sendable_roots)Allowed while the conversation does not deliver to a chat platform. An owner chat bound to one (its meta names a channel), or one that arrived from a platform contact (its meta names a peer_id, kept after unbinding since the contact's next message returns there), keeps the narrow roots: the tool refuses a home file, and the turn-end check refuses it again, so nothing from home is uploaded to WeChat or Telegram
Always refused under that folderAny path through a dot-folder or dot-file (~/.ssh, ~/.aws, ~/.openprogram*, .env); any path through a folder named Library or AppData, where macOS and Windows keep keychains, browser profiles and cookies; key and keystore files (.key, .pem, .p12, .kdbx and similar); names such as id_ed25519, credentials.json, token; and the state directory, whose conversation folders are roots of their own. Uploads and steer images stay out of turn-end attach as before
ChoiceWhy
Not a plain rootThe folder may be $HOME, and send_file can reach a chat platform
Not left outA chat with no project could neither send, link nor open what it built. Claude Code desktop, Codex, Hermes, MiniMax Code and KimiCode all open files the turn wrote from the reply, wherever the working directory is
No per-file journalFiles the turn's tools wrote outside every root are not opened: the working folder covers where they land, and a journal would be a second rule
RouteContract
GET /files/rawProject and relative path for the file panel and center tabs. Always refuses absolute paths; keep this invariant
GET /api/file-rawAbsolute path against readable_roots; nosniff, CSP sandbox, PDF exempted from it for the browser viewer
GET /api/file-readText. A relative path under a root, or an absolute path against readable_roots
GET /api/archive-listEntries from the zip central directory or tar headers, at most 5000, flagged when cut
GET /api/archive-memberOne member up to 32 MB with /api/file-raw's headers. The name is only looked up in the archive index, so ../ reaches nothing
POST /api/file-revealSelects the path in the worker's file manager after the same check. Never opens or runs it; opening in the default app is the desktop app's, which checks the file itself (File menu)
GET /api/file-pathsMany path parameters, at most 64; each mapped to the absolute file it names inside readable_roots or null, without saying whether it was missing, a folder or outside. Relative paths are joined to the chat's working directory. stat only
On the event loop/api/file-paths, /api/file-search and /api/file-resolve find the chat's working directory under its conversation lock, and the search walks folders. That lookup runs in a worker thread in that conversation's lane, so a turn holding the conversation delays only these requests, never the Worker. The search's folder walk runs in a plain worker thread after it, outside the lane, so an @-mention typed while a large folder is walked never queues a Send or Stop of the same chat

Both archive routes take an absolute path or a project id and relative path. FileViewer has one abs switch, so image, PDF, Markdown, line-numbered code and download-card rendering stay in one implementation.

Deferred

ItemWhy not nowWhen
Center tab for user attachmentsThe overlay covers a quick look; project-keyed tabs would need new handling. Reply cards already use tabsWhen someone reads an attachment at length
send_file captionThe marker has no caption field and reply text already accompanies the fileWhen a platform needs text attached to the file
Outbound tool allowlistsend_file is the only outbound entry and checks rootsWhen plugins or MCP tools can trigger delivery
Short-lived signed tokensLocal listener, same-origin guard, root checksFirst addition once the web UI leaves localhost
Syntax highlightingLine-numbered pre is enough; docs-site highlighting is build-time onlyWhen users report a need

Also absent: multiresolution thumbnails for large images.

Target design

Any file, from any source, opens through the same viewer in every interface. User and agent files differ only in their source field.

CapabilitySolvesTodayWhy deferred
One attachment record (id, SHA-256, name, MIME, location, count, source, session, message); text holds only [attachment:<id>]Rename, dedup and cross-session references become queriesA text marker holds everythingNeeds a schema change and history migration; wait for cross-session references
One parser, every interface, including inline terminal images (iTerm2, kitty; file card elsewhere)One rendering decision per resourceTrue on the web. The TUI has no attachment concept and cannot paste imagesIndependent of the web. Peers show the practical gain is modest
Full symmetryOne data model and UI for user and agent filesGrammar, parser, chips and viewer are shared; only fallbacks differPartly done; all four platforms upload
Output as a live pageWatch a document developcanvas writes Markdown blocks with ids; no panel renders themWire format settled. The most valuable next addition; three peers built it

Excluded: global content-addressed blob storage. Each session workdir is committed every turn and stays replayable, so large binaries staying in git history is the accepted cost.

Canvas file content

CallResult
set, append with content=""Empty string is content; the block keeps an empty body and get returns the empty string
Content omitted or nullError, file unchanged
content with body or textExplicit content wins, even when empty

The plain callable and registered tool share this, with the same block format and sandbox path checks.

Eight peers compared
RepositoryInto contextDisplayAgent sends filesViewing, cleanup
claude-code (TUI)Inline base64; bytes in ~/.claude/image-cache/<session>/, 0600. 5 MB, 2000 px, sharp resize, JPEG steps 80/60/40/20. Bridged web and mobile inject paths[Image #N] with OSC-8 link to the system viewer. Non-images: Read <path> (N lines)SendUserMessage attachments: string[]; upload returns file_uuid; 30 MBTUI Markdown and highlighting. PDFs as document blocks or per-page JPEGs. Each session start removes others' caches; 200-entry path LRU
codex-cli (TUI)Base64 input_image in an <image name path> tag. Bytes stay in place. 2048 px, SHA-1 64 MB LRU. Remote URLs rejected[Image #N], not clickable. Kitty and sixel only for the mascotNo general tool. Image generation prints file:// and claims it was shownMarkdown, syntect. file_opener rewrites references to editor URIs
openclaw (web, TUI)Vision models get base64; others get a media://inbound/<id> receipt. Store 0700. Images 6 MB, audio/video 16 MB, documents 100 MB. EXIF normalised, JPEG re-encodedWeb thumbnails open a new tab; cards; audio player with status badges. TUI labelsMEDIA: line and a message tool. Only allowlisted core tools may send local pathsMarkdown-it, DOMPurify. Documents extracted for the model only. Two-minute TTL
opencode (web, TUI)Base64 data URLs in SQLite. @ runs read on submit and injects two synthetic plain-text parts. 5 MB, 2000 px, Lanczos3Image cards with a lightbox; non-images not clickable; @ highlighted in textNo; tool attachments go to model contextGET /file/content; images, audio, SVG, tabs, diffs. Deleted with session rows
hermes-agent (channels)Per-turn routing: native base64 plus a path hint, or vision_analyze text. Documents as paths, text inlined. No first limit; compress to 4 MB after rejectionNative on Telegram and Discord; CLI, TUI and xterm web not clickableMost complete: MEDIA:, send_message, symlink-first root check, per-platform prompts; ![alt](url) extractedRich Markdown. 24-hour TTL
pi-mono (TUI)@file inlined with a <file name> marker. Clipboard writes a temp file and inserts its path. 2000 px, 4.5 MB, can be disabledThe only real inline terminal images (Kitty, iTerm2), off under tmux and screen; tool results only, user images not echoedNoMarkdown, diffs; no PDF, no cleanup of temp images
pi-ai (protocol)Read-only copy of the pi-mono package. Image blocks removed when the model declares no image input; tool-result images split into text and a synthetic user messageNoNoNo
weclaw (WeChat)Images intercepted, saved, “Saved: filename”; agent cannot see them. Voice uses WeChat's transcript. No limitWeChat is the clientImplicit: bare absolute-path lines or ![](url) uploaded and replaced with “Attachment sent”. Roots default to ~/.weclaw/workspace, extension allowlistMarkdown stripped to plain text

Four ways to send a file

DesignUsed byGainsCosts
Tool parameterclaude-code, OpenProgramTyped, existence checked at the toolOne tool call; speech and files are separate actions
Instruction lineopenclaw, hermesSent with speech, no extra round trip; per-channel promptBad paths need checks; partial extraction leaks the line
Implicit scanweclawNothing to learn, no prompt costMentioning a path can send it
Host attaches what the turn producedClaude Code desktop, hermes Deliverable Mode, OpenProgramWorks when the model forgets the tool or a script made the fileNeeds a rule for what counts as produced
Nonecodex-cli, opencode, pi-mono, pi-aiNothing to buildThe model can only paste a path

Instruction-line and implicit designs all keep paths inside allowed roots, resolving symlinks first.

Delivering produced files: peers and choices

Among the 21 harnesses on frontierharness.org/live, none of the strong ones relies on the model remembering to attach every file. They layer a host step, actionable paths in the reply, and a prompt line, with the send tool as a backup.

PeerWhat it does
Claude Code desktop, CoworkPresents files Write and Edit produced by itself; SendUserFile is for files a script made. A setting opens HTML, images, PDF and video it writes
hermes Deliverable ModeScans the reply for absolute or ~ paths ending in .pptx, .docx, .xlsx or .pdf and uploads them; its docs admit the agent does not reach for files by default
Codex app, MiniMax CodeOpens a generated file after the task; lists files generated or referenced as results
Codex, Antigravity promptsAsk the model to write file paths as clickable links and never to say a report is ready without its link
ChoiceWhy
Attach at turn end, not only through the toolClaude Code desktop's split. Office files and PDFs come from scripts, which no edit journal records, and a model whose attachment was refused stops trying
Require a modification during the turnhermes' scan has no such test, so naming an input file sends it back. The time test is one stat and separates a result from a mention
Accept relative paths and linksModels write exports/plan.pptx and markdown links more often than bare absolute paths, which are all hermes reads
Same roots as send_fileThe host step must not reach further than the tool. A file outside the roots is still opened from the link in the reply
fs.read, not replyAttaching is replying, but it shows a file's bytes. reply would let a paired speaker, who may not read the owner's files, have them sent
No new prompt, no MEDIA: tagFewer prompts is the product direction, and a tag still depends on the model remembering

Paths in a reply: peers and choices

PeerWhat it does
Claude Code desktopA path in a reply opens the file pane or browser pane; right-click gives Attach as context, Copy (absolute, relative, filename), Open in, Show in Finder
KimiCodeClick opens File Preview; right-click gives Copy path and Reveal
OpenCode v2Links inline-code paths only after confirming the file exists, after unchecked guesses gave dead links
Codex appPrompts for [app.py](/abs/path/app.py:12) links and opens them in its editor
ChoiceWhy
Link only what the worker confirmsOpenCode v2's fix. A code span like os.path.join has a path's shape; asking costs one batched stat request and no dead link is drawn
One batched route, not /api/file-resolve per pathfile-resolve answers one root-relative path and refuses absolute ones outside the chat's folder; documents/stat answers one path without its absolute form. A reply names many paths, and the menu's Copy needs the real path
Claude Code desktop's menu, in the app's own menu partsThe menu the user named. Built from ContextMenu and MenuRow so it looks like every other right-click menu; one component for paths, cards and changed-file rows
Open in default app in the desktop app, not the workerThe desktop app runs where the user sits; the worker route stays read-only and never runs a file. The app refuses anything the system would run, so the item cannot start a script the agent wrote
Scan settled replies onlyA streaming reply redraws its last block on every delta; links would flicker and the questions would repeat

Other techniques

  • Output as a page: openclaw serves canvas documents embedded with [embed ref=…]; Codex materialises ::codex-inline-vis{ in a sandboxed viewer (2 MB, strict CSP); pi-mono's /share publishes a session as a private gist.
  • Signed tokens: openclaw's mediaTicket, v1.<payload>.<signature>, five-minute TTL.
  • Chips as editing units: claude-code sends an image only while its [Image #N] stays in the text.
  • Hermes rewrites host cache paths to container paths. Codex has view_image.

Implementation status

ItemStatus
Marker grammar, root policy, inbound paths, chips, overlay, reply cards, file routes, send_file with no review, files the turn produced, paths in a reply as links, the file menu, channel delivery on all four platforms, canvas content rulesImplemented
Center tab for user attachments, caption, outbound allowlist, signed tokens, highlighting, multiresolution thumbnailsNot implemented
Attachment record, TUI inline images, live canvas panelNot implemented
document modality (model input in openprogram/models/providers/types.py) and a delivery-choice capability switchNot implemented
Code locations
Marker, roots
openprogram/state/attachments.py
Web persistence
openprogram/interfaces/server/ws_actions/chat/attachments.py
Channel inbound
openprogram/interfaces/channels/inbound/_attachments.py
Channel delivery
openprogram/interfaces/channels/inbound/_conversation.py, _transport.py
Tool, turn end
openprogram/programs/tools/interaction/send_file.py, openprogram/runtime/conversation/turn_runtime/__init__.py
Routes
openprogram/interfaces/server/routes/files/file_search.py, archives.py
Chips, cards
apps/web/components/chat/messages/attachments/
Paths in a reply, file menu
apps/web/components/chat/messages/bubbles/prose-file-links.tsx, apps/web/lib/files/prose-file-paths.ts, file-path-lookup.ts, apps/web/components/files/file-path-menu.tsx, apps/desktop/main/files/open-default.js
Viewer
apps/web/components/files/file-viewer.tsx, preview/archive-preview.tsx
Last updated · 2026-11-25