MCPcopy Create free account
hub / github.com/WebMCP-org/chrome-devtools-quickstart / runAgentBenchmark

Function runAgentBenchmark

benchmark/simple-benchmark.ts:188–259  ·  view source on GitHub ↗
(options: BenchmarkOptions)

Source from the content-addressed store, hash-verified

186}
187
188async function runAgentBenchmark(options: BenchmarkOptions): Promise<BenchmarkResult> {
189 const toolUsage: ToolUsage = {};
190 let imageTokens = 0;
191
192 const q = query({
193 prompt: options.task,
194 options: {
195 systemPrompt: options.systemPrompt,
196 mcpServers: options.mcpServers,
197 disallowedTools: options.disallowedTools,
198 permissionMode: "bypassPermissions",
199 allowDangerouslySkipPermissions: true,
200 },
201 });
202
203 let resultMessage: SDKMessage | null = null;
204 for await (const message of q) {
205 if (message.type === "assistant") {
206 for (const block of message.message.content) {
207 if (block.type === "tool_use") {
208 const toolName = block.name;
209 toolUsage[toolName] = (toolUsage[toolName] || 0) + 1;
210 }
211 }
212 }
213
214 if (message.type === "user" && "tool_use_result" in message && message.tool_use_result) {
215 const result = message.tool_use_result as {
216 content?: Array<{ type: string; data?: string; mimeType?: string }>;
217 };
218 if (result.content) {
219 for (const item of result.content) {
220 if (item.type === "image" && item.data && item.mimeType) {
221 const tokens = calculateImageTokensFromBase64(
222 item.data,
223 item.mimeType as ImageMimeType
224 );
225 if (tokens) imageTokens += tokens;
226 }
227 }
228 }
229 }
230
231 if (message.type === "result") {
232 resultMessage = message;
233 }
234 }
235
236 if (!resultMessage || resultMessage.type !== "result") {
237 return {
238 success: false,
239 inputTokens: 0,
240 outputTokens: 0,
241 imageTokens: 0,
242 totalCostUsd: 0,
243 durationMs: 0,
244 numTurns: 0,
245 toolUsage,

Callers 2

runScreenshotBenchmarkFunction · 0.70
runWebMCPBenchmarkFunction · 0.70

Calls 1

Tested by

no test coverage detected