GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(server): add experimental GET /api/experimental/media/:hash and opt-in experimental-media-uri capability by kitlangton · Pull Request #59103 · anomalyco/opencode

Conversation

@kitlangton

@kitlangton kitlangton commented Oct 25, 2026 •
edited by opencode-agent Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

What it does

Lets a client skip inline base64 when reading a session and fetch attachment bytes only when it needs them. It's experimental and opt-in at both ends: the client has to ask for refs, and the session's location needs experimental.media_blob on, which is off by default. Every other client and session gets inline base64 exactly as today.

Replaces #58657, which GitHub marked merged into its stack base while the stack was being reordered. Nothing from it reached dev.

Stack, built on the merged #58656: write (#58741, merged) → wire (this PR) → app (#59104) → backfill (#58742, optional, can land later).

Why

With media stored once in blob (#58741), message reads still turn every ref back into base64, so each load of a long session with screenshots re-sends every image, a third larger than the raw bytes. With refs, a read carries a short media:<hash> per file, and a client fetches each image once and caches it. Before → after bytes per read have not been measured yet.

How it works

  1. A client opts in with X-OpenCode-Capabilities: experimental-media-uri. Only session.messages, session.message and session.inbox.list have ref variants. They return stored files as media:<hash> refs with their size in bytes. No route path is sent or stored.
  2. Whether refs are sent follows the flag in the session's own location config, not the server's working directory. If that config can't be resolved, the read logs a warning and falls back to inline.
  3. GET /api/experimental/media/:hash (generated client: experimental.media.get, OpenAPI tag experimental) serves a blob only while a message or inbox item still references it. A blob that's been released or is waiting to be swept returns 404. Responses carry immutable Cache-Control, an ETag with 304 support, nosniff and a sandbox CSP. Anything other than PNG, JPEG, GIF or WebP downloads as application/octet-stream.
  4. A ref whose blob is gone reads as the [media unavailable: <name> (<mime>)] placeholder instead of a dead link.
  5. A prompt may send a media:<hash> ref back as an attachment. The server re-admits the stored bytes unchanged, without normalizing them again, and rejects a ref nothing references anymore.

Risk

Server, protocol and the generated client. The new route and response shapes are experimental, and clients that don't opt in see no change. These still send media inline on purpose: session.context, the session.prompt response, session export and import, and the runner's model requests. Legacy /api/media/ URLs are not supported, since refs are the only form sent or accepted.

Proof

  • bun test test/media.test.ts (packages/server): 2 pass. They cover the ref and inline shape switch; headers, ETag and 304; the missing-blob placeholder; following the flag from the session's project config when the server's own directory has it off; and a 404 plus a rejected prompt for an unreferenced blob.
  • bun test for the core prompt, owned, projector and store tests: 92 pass.
  • bun run typecheck (core, server, client): clean.

Added by the opencode bot (AI-generated).

Related: #36444, #58436

Public API: adds experimental GET /api/experimental/media/:hash (operationId experimental.media.get), an opt-in X-OpenCode-Capabilities: experimental-media-uri header for message/inbox reads, media: prompt attachments and new Media* schemas (backwards compatible)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kitlangton
feat: serve stored media as refs to clients that opt into experimenta…
8aea935
…l-media-uri

Clients that send X-OpenCode-Capabilities: experimental-media-uri get user
files and tool results stored in blob as media:<hash> refs with their size
and dimensions instead of inline base64, from session.messages,
session.message and session.inbox.list, when experimental.media_blob is on
in the session's own location (the config its media was written under).
Refs whose blob is gone become the same unavailable placeholder inline
readers get. Every other reader, the runner and export stay inline.

GET /api/experimental/media/:hash serves one blob that a stored message or
inbox item still references, with an immutable ETag, 304 support, nosniff
and a sandbox CSP; anything but a raster image is sent as an
application/octet-stream attachment. session.prompt accepts a referenced
media:<hash> ref as an attachment URI and re-admits its stored bytes as is.
@github-actions github-actions Bot added the contributor label Oct 25, 2026
This was referenced Oct 25, 2026
feat(app): opt into experimental-media-uri and keep draft media bytes local #59104
Merged
feat(core): add byte-preserving offline media_blob backfill for legacy rows #58742
Closed
feat(server): add experimental GET /api/experimental/media/:hash and opt-in experimental-media-uri capability #58657
Merged
@kitlangton
kitlangton marked this pull request as ready for review October 26, 2026 00:08
opencode-agent[bot]
opencode-agent Bot reviewed Oct 26, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found nothing that blocks a merge, and the change works as described. The new server tests run the real server through ServerFetch and the generated client, both with and without the experimental-media-uri header and with experimental.media_blob on and off. They pass, as does session-owned.test.ts, and typecheck:tsc is clean for core, server and client.

Public API (additive, backwards compatible):

  • New GET /api/experimental/media/:hash (media.get, tag experimental; promise client experimental.media.get, left out of the effect client).
  • New opt-in request header X-OpenCode-Capabilities: experimental-media-uri. It changes session.messages, session.message and session.inbox.list only when the session's location also has experimental.media_blob on.
  • New schemas: Prompt.MediaRef, Prompt.MediaFileAttachment, Prompt.Attachment, Session.Message.MediaUser/MediaInfo, Session.Inbox.MediaUser/MediaUserPayload/MediaInfo.
  • Prompt attachments now also accept a media:<hash> URI.
  • server.experimental now holds both the persistent PTY routes and the media route.
  • Clients that don't send the header see no change.

Worth a look:

  • With refs on, file items in assistant tool output also come back as media:<hash>. describe only adds bytes/width/height to user and inbox files, so tool items have no size, and the spec still types Tool.Content.uri as a plain string. Opted-in clients have to handle that case without it being documented.
  • test/media.test.ts is about 360 lines for 2 tests, each a long chain of checks. Splitting it into a few small cases would make failures easier to locate: ref vs. inline shape, headers/304, the missing-blob placeholder, and the unreferenced-blob 404 with the rejected prompt.
  • SessionBlob.split is a new export that only the test uses here, so it could move to the backfill PR (#58742).

Related: #36444, #58436

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kitlangton
test(server): release media test servers before removing their temp dir
47f6797
opencode-agent[bot]
opencode-agent Bot reviewed Oct 26, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit changes only the test. Each test now takes its temp directory from tmpdirScoped before starting the servers, so the servers close the database before the directory is removed (Windows can't delete an open database). The assertions are the same as before. On the new head, bun test test/media.test.ts passes (2 tests) and server typecheck:tsc is clean. Production code and the public API are unchanged since my last review, and I have nothing new to raise.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kitlangton
fix: only offer media refs the route can serve; name the route experi…
20a0be9
…mental.media.get
opencode-agent[bot]
opencode-agent Bot reviewed Oct 26, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit is sound. Opted-in reads now only offer a media: ref for a blob that something still references, using the same check the media route uses. Any other stored blob reads as the [media unavailable: …] placeholder instead of a ref that would 404, and the added test checks both the 404 and the placeholder. media.test.ts passes (2 tests), typecheck:tsc is clean in core and server, and re-running the protocol and client generators gives no diff.

Public API: the OpenAPI operationId changes from media.get to experimental.media.get. The route is new in this PR, so nothing released depends on the old id, and the generated client already calls it experimental.media.get. Nothing else changed. I have no new concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kitlangton
kitlangton merged commit e928d4f into dev Oct 26, 2026
21 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@kitlangton
kitlangton deleted the media-wire branch October 26, 2026 04:33
@amrkmn amrkmn mentioned this pull request Oct 27, 2026
opencode 2.2.0 amrkmn/homebrew-tap#1182
Closed
1 task
@github-actions github-actions Bot mentioned this pull request Oct 28, 2026
Tool release: OpenCode 2 v2.2.0 (was v2.1.4) agent-sh/agnix#1737
Closed
@opencodejr opencodejr Bot mentioned this pull request Oct 28, 2026
app: the attachment card in a sent message is display-only — the uploaded file cannot be opened or downloaded #59896
Open
@kitlangton kitlangton mentioned this pull request Oct 29, 2026
feat(tui): load stored images by reference, like desktop #60116
Merged
@kobzevvv kobzevvv mentioned this pull request Oct 29, 2026
chore(upstream): порт v2.2.1 — 71 в порт, 67 на решение gpt-mem/opencode-mem#219
Open
@ksy90101 ksy90101 mentioned this pull request Nov 18, 2026
feat(opencode): 세션 미디어를 media:<hash> 참조로 blob 테이블에 한 번만 저장 team-monolith-product/enk-opencode#347
Draft
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencode-agent opencode-agent[bot] opencode-agent[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@kitlangton
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.