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: local resource links with file:/ URI are treated as text #60298
An ACP resource_link for a local file is treated differently depending on the valid spelling of its file URI. file:/tmp/a.txt and file:///tmp/a.txt resolve to the same local file, but the former becomes a text link instead of a file attachment. The prompt preparation path therefore leaves it out of the attachment list; the model receives a reference rather than the requested file contents.
Reproduction
From packages/cli on dev commit 82666b6612cdb2ba13a7a26e150b21e897a80373:
bun -e 'import { promptContentToParts } from "./src/acp/content.ts"; import { fileURLToPath } from "node:url"; for (const uri of ["file:/tmp/a.txt", "file:///tmp/a.txt"]) console.log(uri, fileURLToPath(uri), JSON.stringify(promptContentToParts([{type:"resource_link",uri,name:"a.txt",mimeType:"text/plain"}])));'
Expected: both local file URIs are treated as the same attachment. resourceLinkToPart checks a literal file:// prefix rather than the parsed URI protocol; prepare collects only file parts as attachments. The reproduction exercises the actual content converter, not a full ACP client; I have not established which clients emit the single-slash spelling. The affected source matches the current upstream dev blob.
Thanks for the clear report. I can confirm this on the latest dev (d3ad3da); the ACP content code hasn't changed since the commit you tested.
The script below calls promptContentToParts with a resource_link (name: "a.txt", mimeType: "text/plain") under three URI spellings. All three resolve to /tmp/a.txt:
URI
Result
file:/tmp/a.txt
text link [a.txt](file:/tmp/a.txt)
file:///tmp/a.txt
file attachment
file://localhost/tmp/a.txt
file attachment
As you found, resourceLinkToPart checks for the literal file:// prefix, and prepare only collects file parts as attachments. So the single-slash form reaches the model as a reference, not as the file. I've passed this to the maintainers.
Reproduction script (repro.ts)
// Run from packages/cli of an opencode checkout: bun /workspace/repro/repro.ts [/path/to/repo]importpathfrom"node:path"import{fileURLToPath}from"node:url"constrepo=process.argv[2]??"/workspace/repo"const{ promptContentToParts }=awaitimport(path.join(repo,"packages/cli/src/acp/content.ts"))letbad=falsefor(consturiof["file:/tmp/a.txt","file:///tmp/a.txt","file://localhost/tmp/a.txt"]){constparts=promptContentToParts([{type: "resource_link", uri,name: "a.txt",mimeType: "text/plain"}])console.log(uri,"->",fileURLToPath(uri),JSON.stringify(parts))if(parts[0]?.type!=="file")bad=true}console.log(bad ? "BUG: some local file URIs were not turned into file attachments" : "OK")
Activity
opencodejr commentedon Oct 29, 2026
Thanks for the clear report. I can confirm this on the latest
dev(d3ad3da); the ACP content code hasn't changed since the commit you tested.The script below calls
promptContentToPartswith aresource_link(name: "a.txt",mimeType: "text/plain") under three URI spellings. All three resolve to/tmp/a.txt:file:/tmp/a.txt[a.txt](file:/tmp/a.txt)file:///tmp/a.txtfile://localhost/tmp/a.txtAs you found,
resourceLinkToPartchecks for the literalfile://prefix, andprepareonly collects file parts as attachments. So the single-slash form reaches the model as a reference, not as the file. I've passed this to the maintainers.Reproduction script (repro.ts)
Run it:
bun repro.tsfix(acp): normalize local file resource URIs