Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): prevent preview_snapshot from bricking sessions with oversized images #11624

ClosedExotic209093(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/11624/headopened View on GitHub

Showing 4 changed files with 13 additions and 49 deletions (loading 1).

x
0 of 4 viewed, 4 left
2 additions and 2 deletionsapps/server/src/mcp/toolkits/preview/handlers.tsModified
View file
@@ -197,8 +197,8 @@
preview_set_appearance: (input) =>
invokeTargeted<PreviewAutomationSetColorSchemeResult>("setColorScheme", input),
preview_snapshot: (input) => {
- // Output selection and saving are MCP-only; the browser still produces a complete snapshot.
- const { includeImage: _includeImage, save: _save, ...operationInput } = input ?? {};
+ // Saving is MCP-only; the browser still produces a complete snapshot.
+ const { save: _save, ...operationInput } = input ?? {};
return invokeTargeted<PreviewAutomationSnapshot>("snapshot", operationInput);
preview_click: (input) => invokeTargeted<object>("click", input, input.timeoutMs),
1 addition and 7 deletionsapps/server/src/mcp/toolkits/preview/tools.tsModified
View file
@@ -119,15 +119,9 @@
export const PreviewSnapshotTool = readonlyBrowserTool(
Tool.make("preview_snapshot", {
description:
- "Inspect a page before interacting. Pass tabId to inspect a specific tab; omit it to use this agent session's current tab. Returns page state, semantic elements, diagnostics, action history, and a PNG screenshot. Set includeImage=false for text-only output with the same page metadata. Set save=true to also write the PNG to disk and get screenshotPath back; embed that path in your reply as ![alt](screenshotPath) so the user sees it. This is the only way to show the user a screenshot; the image in the tool result is not saved anywhere.",
+ "Inspect a page before interacting. Pass tabId to inspect a specific tab; omit it to use this agent session's current tab. Returns page state, semantic elements, diagnostics, action history, and screenshot metadata (mimeType, width, height); the screenshot itself is not embedded in the tool result. Set save=true to write the PNG to disk and get screenshotPath back; embed that path in your reply as ![alt](screenshotPath) so the user sees it. This is the only way to show the user a screenshot.",
parameters: Schema.Struct({
...PreviewAutomationTabTargetInput.fields,
- includeImage: Schema.optional(
- Schema.Boolean.annotate({
- description:
- "Include the PNG image in the tool response. Defaults to true. Set false for text-only output.",
- }),
- ),
save: Schema.optional(