diff --git a/packages/coding-agent/src/prompts/tools/read.md b/packages/coding-agent/src/prompts/tools/read.md index 4dafa54b5..d8b0aab25 100644 --- a/packages/coding-agent/src/prompts/tools/read.md +++ b/packages/coding-agent/src/prompts/tools/read.md @@ -46,7 +46,11 @@ Extracts text from PDF, Word, PowerPoint, Excel, RTF, and EPUB. Notebooks (`.ipy # Images +{{#if INSPECT_IMAGE_ENABLED}} Reading an image path returns metadata (mime, bytes, dimensions, channels, alpha). For actual visual analysis, call `inspect_image` with the path and a question describing what to inspect. +{{else}} +Reading an image path returns the decoded image inline (PNG, JPEG, GIF, WEBP) for direct visual analysis. +{{/if}} # Archives diff --git a/packages/coding-agent/src/tools/read.ts b/packages/coding-agent/src/tools/read.ts index 20efd4e98..64cd32d37 100644 --- a/packages/coding-agent/src/tools/read.ts +++ b/packages/coding-agent/src/tools/read.ts @@ -689,6 +689,7 @@ export class ReadTool implements AgentTool { DEFAULT_MAX_LINES: String(DEFAULT_MAX_LINES), IS_HL_MODE: displayMode.hashLines, IS_LINE_NUMBER_MODE: !displayMode.hashLines && displayMode.lineNumbers, + INSPECT_IMAGE_ENABLED: this.#inspectImageEnabled, }); } diff --git a/packages/coding-agent/test/tools.test.ts b/packages/coding-agent/test/tools.test.ts index 954c9a188..ba64d65f3 100644 --- a/packages/coding-agent/test/tools.test.ts +++ b/packages/coding-agent/test/tools.test.ts @@ -711,6 +711,19 @@ describe("Coding Agent Tools", () => { expect(result.content.some(c => c.type === "image")).toBe(false); }); + it("omits inspect_image from the description when the tool is disabled", () => { + const enabled = new ReadTool( + createTestToolSession(testDir, Settings.isolated({ "inspect_image.enabled": true })), + ); + const disabled = new ReadTool( + createTestToolSession(testDir, Settings.isolated({ "inspect_image.enabled": false })), + ); + + expect(enabled.description).toContain("inspect_image"); + expect(disabled.description).not.toContain("inspect_image"); + expect(disabled.description).toContain("inline"); + }); + it("should treat files with image extension but non-image content as text", async () => { const testFile = path.join(testDir, "not-an-image.png"); fs.writeFileSync(testFile, "definitely not a png");