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:
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user