Skip to content

Commit 38c641a

Browse files
zerone0xclaude
andauthored
fix(tool): treat .fbs files as text instead of images (#9276)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 501ef2d commit 38c641a

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

packages/opencode/src/tool/read.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ export const ReadTool = Tool.define("read", {
5959
throw new Error(`File not found: ${filepath}`)
6060
}
6161

62-
const isImage = file.type.startsWith("image/") && file.type !== "image/svg+xml"
62+
// Exclude SVG (XML-based) and vnd.fastbidsheet (.fbs extension, commonly FlatBuffers schema files)
63+
const isImage =
64+
file.type.startsWith("image/") && file.type !== "image/svg+xml" && file.type !== "image/vnd.fastbidsheet"
6365
const isPdf = file.type === "application/pdf"
6466
if (isImage || isPdf) {
6567
const mime = file.type

packages/opencode/test/tool/read.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,33 @@ describe("tool.read truncation", () => {
300300
},
301301
})
302302
})
303+
304+
test(".fbs files (FlatBuffers schema) are read as text, not images", async () => {
305+
await using tmp = await tmpdir({
306+
init: async (dir) => {
307+
// FlatBuffers schema content
308+
const fbsContent = `namespace MyGame;
309+
310+
table Monster {
311+
pos:Vec3;
312+
name:string;
313+
inventory:[ubyte];
314+
}
315+
316+
root_type Monster;`
317+
await Bun.write(path.join(dir, "schema.fbs"), fbsContent)
318+
},
319+
})
320+
await Instance.provide({
321+
directory: tmp.path,
322+
fn: async () => {
323+
const read = await ReadTool.init()
324+
const result = await read.execute({ filePath: path.join(tmp.path, "schema.fbs") }, ctx)
325+
// Should be read as text, not as image
326+
expect(result.attachments).toBeUndefined()
327+
expect(result.output).toContain("namespace MyGame")
328+
expect(result.output).toContain("table Monster")
329+
},
330+
})
331+
})
303332
})

0 commit comments

Comments
 (0)