chore: do not return fullPage screenshots to the LLM (#849)
This commit is contained in:
@@ -75,11 +75,16 @@ const screenshot = defineTabTool({
|
|||||||
|
|
||||||
const buffer = locator ? await locator.screenshot(options) : await tab.page.screenshot(options);
|
const buffer = locator ? await locator.screenshot(options) : await tab.page.screenshot(options);
|
||||||
response.addResult(`Took the ${screenshotTarget} screenshot and saved it as ${fileName}`);
|
response.addResult(`Took the ${screenshotTarget} screenshot and saved it as ${fileName}`);
|
||||||
|
|
||||||
|
// https://github.com/microsoft/playwright-mcp/issues/817
|
||||||
|
// Never return large images to LLM, saving them to the file system is enough.
|
||||||
|
if (!params.fullPage) {
|
||||||
response.addImage({
|
response.addImage({
|
||||||
contentType: fileType === 'png' ? 'image/png' : 'image/jpeg',
|
contentType: fileType === 'png' ? 'image/png' : 'image/jpeg',
|
||||||
data: buffer
|
data: buffer
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
|
|||||||
@@ -264,12 +264,7 @@ test('browser_take_screenshot (fullPage: true)', async ({ startClient, server },
|
|||||||
{
|
{
|
||||||
text: expect.stringContaining('fullPage: true'),
|
text: expect.stringContaining('fullPage: true'),
|
||||||
type: 'text',
|
type: 'text',
|
||||||
},
|
}
|
||||||
{
|
|
||||||
data: expect.any(String),
|
|
||||||
mimeType: 'image/png',
|
|
||||||
type: 'image',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user