You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
acp: embedded blobs without optional mimeType are silently dropped #64687
ACP session/prompt silently drops an embedded blob resource when mimeType is omitted. The same bytes are attached when mimeType is supplied. ACP v1 makes this field optional.
The resource branch in content.ts returns an empty array before prompt submission.
OpenCode version
dev at a61f5ea83460c197229e67b9c07c49ea87615385 (2.3.0 source), Bun 1.4.4.
Expected: the embedded bytes reach the session as an attachment. Actual: the session receives the text with no attachment. Adding "mimeType": "application/pdf" forwards it correctly. The short payload above is only a PDF-signature fixture to demonstrate forwarding.
Reproduced with the real ACP wire fixture in packages/cli/test/acp/prompt.test.ts, asserting the submitted attachment list.
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the precise report. I reproduced this with the released @opencode/cli 2.3.0, driving opencode acp over stdio with your exact session/prompt payload. A local mock OpenAI-compatible endpoint stood in for the model so I could see what OpenCode sends it:
Without mimeType: the user message that reached the model was only "Inspect this file". The PDF blob was gone, and the prompt still ended in end_turn with no error or warning to the ACP client.
With "mimeType": "application/pdf": the message carried a file part with data:application/pdf;base64,JVBERi0xLjQK.
It still happens on the latest dev (a61f5ea), run from source. The cause looks like the line you pointed to in packages/cli/src/acp/content.ts: the resource case returns [] when a blob has no mimeType, while the ACP SDK it uses marks that field as optional.
The script below reproduces it. The only thing faked is the model endpoint, and the block is dropped before any model call.
Reproduction script (repro.ts)
// Reproduces #64687: ACP embedded blob resource without mimeType is dropped.// Starts a mock OpenAI-compatible endpoint (stands in for the model), runs `opencode acp`// (or the checkout's CLI when OC_DEV is set), sends two prompts, and prints what reached the model.import{spawn}from"node:child_process"import{mkdirSync,writeFileSync}from"node:fs"constbodies: any[]=[]constserver=Bun.serve({port: 0,asyncfetch(req){consturl=newURL(req.url);if(process.env.DUMP)console.error("REQ",req.method,url.pathname)if(req.method==="POST"&&url.pathname.endsWith("/chat/completions")){{constj=awaitreq.json();bodies.push(j);if(process.env.DUMP)console.error(JSON.stringify(j).slice(0,1500))}constchunk=(d: any)=>`data: ${JSON.stringify(d)}\n\n`constbase={id: "c1",object: "chat.completion.chunk",created: 0,model: "mock"}constsse=chunk({ ...base,choices: [{index: 0,delta: {role: "assistant",content: "ok"},finish_reason: null}]})+chunk({ ...base,choices: [{index: 0,delta: {},finish_reason: "stop"}],usage: {prompt_tokens: 1,completion_tokens: 1,total_tokens: 2}})+"data: [DONE]\n\n"returnnewResponse(sse,{headers: {"content-type": "text/event-stream"}})}returnnewResponse(JSON.stringify({data: []}),{headers: {"content-type": "application/json"}})},})constproj="/workspace/repro/proj"mkdirSync(proj,{recursive: true})writeFileSync(`${proj}/opencode.jsonc`,JSON.stringify({providers: {mock: {name: "Mock",env: ["MOCK_API_KEY"],package: "@opencode/ai/providers/openai-compatible",settings: {baseURL: `http://127.0.0.1:${server.port}/v1`},models: {m: {name: "Mock",capabilities: {tools: false,input: ["text","image","pdf"],output: ["text"]}}}}},model: "mock/m",}))constdev=process.env.OC_DEVconstcmd=dev
? ["bun",["--conditions=browser",`--preload=${dev}/packages/tui/node_modules/@opentui/solid/scripts/preload.js`,`${dev}/packages/cli/src/index.ts`,"acp"]]
: ["opencode",["acp"]]constchild=spawn(cmd[0]asstring,cmd[1]asstring[],{cwd: proj,env: { ...process.env,MOCK_API_KEY: "x", ...(dev ? {BUN_OPTIONS: `--conditions=browser --preload=${dev}/packages/tui/node_modules/@opentui/solid/scripts/preload.js`} : {})},stdio: ["pipe","pipe","inherit"]})letbuf=""constpending=newMap<number,(v: any)=>void>()child.stdout.on("data",(d)=>{buf+=dletiwhile((i=buf.indexOf("\n"))>=0){constline=buf.slice(0,i);buf=buf.slice(i+1)if(!line.trim())continueconstmsg=JSON.parse(line)if(msg.id!==undefined&&pending.has(msg.id)){pending.get(msg.id)!(msg);pending.delete(msg.id)}elseif(msg.id!==undefined&&msg.method)child.stdin.write(JSON.stringify({jsonrpc: "2.0",id: msg.id,result: {outcome: {outcome: "cancelled"}}})+"\n")}})letnext=1constrpc=(method: string,params: any)=>newPromise<any>((res)=>{constid=next++;pending.set(id,res)child.stdin.write(JSON.stringify({jsonrpc: "2.0", id, method, params })+"\n")})constinit=awaitrpc("initialize",{protocolVersion: 1,clientCapabilities: {}})console.log("embeddedContext:",JSON.stringify(init.result?.agentCapabilities?.promptCapabilities))for(constwithMimeof[false,true]){consts=awaitrpc("session/new",{cwd: proj,mcpServers: []})if(s.error){console.log("session/new error",JSON.stringify(s.error));break}constresource: any={uri: "mcp://context/report.pdf",blob: "JVBERi0xLjQK"}if(withMime)resource.mimeType="application/pdf"constbefore=bodies.lengthconstr=awaitrpc("session/prompt",{sessionId: s.result.sessionId,prompt: [{type: "text",text: "Inspect this file"},{type: "resource", resource }]})constbody=bodies.slice(before).find((b: any)=>!String(b.messages?.[0]?.content).startsWith("You name conversations"))constuser=body?.messages?.filter((m: any)=>m.role==="user").at(-1)console.log(`\n== mimeType ${withMime ? "present" : "omitted"} == stopReason=${r.result?.stopReason??JSON.stringify(r.error)}`)console.log("user message sent to model:",JSON.stringify(user?.content,(k,v)=>typeofv==="string"&&v.length>80 ? v.slice(0,80)+"…" : v))}child.kill();server.stop(true);process.exit(0)
Activity
opencodejr commentedon Nov 18, 2026
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the precise report. I reproduced this with the released
@opencode/cli2.3.0, drivingopencode acpover stdio with your exactsession/promptpayload. A local mock OpenAI-compatible endpoint stood in for the model so I could see what OpenCode sends it:mimeType: the user message that reached the model was only"Inspect this file". The PDF blob was gone, and the prompt still ended inend_turnwith no error or warning to the ACP client."mimeType": "application/pdf": the message carried afilepart withdata:application/pdf;base64,JVBERi0xLjQK.It still happens on the latest
dev(a61f5ea), run from source. The cause looks like the line you pointed to inpackages/cli/src/acp/content.ts: theresourcecase returns[]when a blob has nomimeType, while the ACP SDK it uses marks that field as optional.The script below reproduces it. The only thing faked is the model endpoint, and the block is dropped before any model call.
Reproduction script (repro.ts)
Run it:
bun repro.ts