feat(read): conditioned inspect_image docs on feature flag

- Updated read tool prompt to show alternate image description when inspect_image is disabled.
- Passed INSPECT_IMAGE_ENABLED flag into prompt rendering context.
- Added test verifying description omits inspect_image references when disabled.
This commit is contained in:
can1357
2026-05-30 21:24:14 +02:00
parent 4ee35bec7a
commit 725539aeeb
3 changed files with 18 additions and 0 deletions
@@ -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
+1
View File
@@ -689,6 +689,7 @@ export class ReadTool implements AgentTool<typeof readSchema, ReadToolDetails> {
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,
});
}
+13
View File
@@ -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");