Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions packages/core/lib/v3/handlers/v3AgentHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ export class V3AgentHandler {
: allReasoning || "Task completed successfully";
}
}
// Intercept screenshot tool output for evals (hybrid mode only)
if (this.mode === "hybrid" && toolCall.toolName === "screenshot") {
const screenshotOutput = event.toolResults?.[i]?.output;
this.v3.bus.emit(
"agent_screensot_taken_event",
Buffer.from(screenshotOutput.base64, "base64"),
);
}
const mappedActions = mapToolResultToActions({
toolCallName: toolCall.toolName,
toolResult,
Expand All @@ -183,17 +191,9 @@ export class V3AgentHandler {
}
state.currentPageUrl = (await this.v3.context.awaitActivePage()).url();

// Capture screenshot after tool execution (only for evals)
if (process.env.EVALS === "true") {
try {
await this.captureAndEmitScreenshot();
} catch (e) {
this.logger({
category: "agent",
message: `Warning: Failed to capture screenshot: ${getErrorMessage(e)}`,
level: 1,
});
}
// Capture screenshot after tool execution (only for evals, DOM mode)
if (process.env.EVALS === "true" && this.mode === "dom") {
await this.captureAndEmitScreenshot();
}
}

Expand Down
7 changes: 0 additions & 7 deletions packages/evals/types/screenshotCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,3 @@ export interface ScreenshotCollectorOptions {
interval?: number;
maxScreenshots?: number;
}

// Minimal page-like interface: supports screenshot() and optional event hooks
export type ScreenshotCapablePage = {
screenshot: (...args: []) => Promise<Buffer | string>;
on?: (event: string, listener: (...args: []) => void) => void;
off?: (event: string, listener: (...args: []) => void) => void;
};
Loading