-
Notifications
You must be signed in to change notification settings - Fork 966
Add more agent evals #961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tkattkat
wants to merge
10
commits into
main
Choose a base branch
from
more-evals
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+904
−77
Open
Add more agent evals #961
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6ee4de7
add more evals for agent
tkattkat bac6f01
add more evals
tkattkat d30d4d0
update evals config
tkattkat d924370
add changeset
tkattkat fffe986
update eval
tkattkat 81f0e1a
offload initialization of agent to the runner
tkattkat 55ef435
update type
tkattkat 7b4b030
update steps on eval
tkattkat d6c6dc0
add more validation to evals + update default models for agent in tas…
tkattkat 439494e
update kith eval
tkattkat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@browserbasehq/stagehand": patch | ||
--- | ||
|
||
Add more evals for stagehand agent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Evaluator } from "@/evals/evaluator"; | ||
import { EvalFunction } from "@/types/evals"; | ||
|
||
export const all_recipes: EvalFunction = async ({ | ||
debugUrl, | ||
sessionUrl, | ||
stagehand, | ||
logger, | ||
agent, | ||
}) => { | ||
try { | ||
await stagehand.page.goto("https://www.allrecipes.com/"); | ||
const evaluator = new Evaluator(stagehand); | ||
const agentResult = await agent.execute({ | ||
instruction: | ||
"Search for a recipe for Beef Wellington on Allrecipes that has at least 200 reviews and an average rating of 4.5 stars or higher. List the main ingredients required for the dish.", | ||
maxSteps: 20, | ||
}); | ||
|
||
const { evaluation, reasoning } = await evaluator.evaluate({ | ||
question: "Did the agent find a recipe for Beef Wellington", | ||
}); | ||
|
||
logger.log(agentResult); | ||
|
||
const success = | ||
agentResult.success && | ||
evaluation === "YES" && | ||
stagehand.page.url() === | ||
"https://www.allrecipes.com/recipe/16899/beef-wellington/"; | ||
|
||
if (!success) { | ||
return { | ||
_success: false, | ||
message: reasoning, | ||
debugUrl, | ||
sessionUrl, | ||
logs: logger.getLogs(), | ||
}; | ||
} | ||
|
||
return { | ||
_success: true, | ||
debugUrl, | ||
sessionUrl, | ||
logs: logger.getLogs(), | ||
}; | ||
} catch (error) { | ||
return { | ||
_success: false, | ||
error, | ||
debugUrl, | ||
sessionUrl, | ||
logs: logger.getLogs(), | ||
} as unknown as ReturnType<EvalFunction> extends Promise<infer R> | ||
? R | ||
: never; | ||
} finally { | ||
await stagehand.close(); | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//this eval is expected to fail due to issues scrolling within the trade in dialog | ||
import { EvalFunction } from "@/types/evals"; | ||
import { z } from "zod"; | ||
|
||
export const apple_trade_in: EvalFunction = async ({ | ||
debugUrl, | ||
sessionUrl, | ||
stagehand, | ||
logger, | ||
agent, | ||
}) => { | ||
try { | ||
await stagehand.page.goto("https://www.apple.com/shop/trade-in"); | ||
const agentResult = await agent.execute({ | ||
instruction: | ||
"Find out the trade-in value for an iPhone 13 Pro Max in good condition on the Apple website.", | ||
maxSteps: 30, | ||
}); | ||
|
||
const { tradeInValue } = await stagehand.page.extract({ | ||
modelName: "google/gemini-2.5-flash", | ||
instruction: | ||
"Extract the trade-in value for an iPhone 13 Pro Max in good condition on the Apple website. it will be inside this text : Get x trade-in credit toward a new iPhone', provide just the number", | ||
schema: z.object({ | ||
tradeInValue: z.number(), | ||
}), | ||
}); | ||
|
||
const success = | ||
agentResult.success && | ||
tradeInValue === 360 && | ||
stagehand.page.url().includes("https://www.apple.com/shop/trade-in"); | ||
|
||
if (!success) { | ||
return { | ||
_success: false, | ||
message: agentResult.message, | ||
debugUrl, | ||
sessionUrl, | ||
logs: logger.getLogs(), | ||
}; | ||
} | ||
return { | ||
_success: true, | ||
debugUrl, | ||
sessionUrl, | ||
logs: logger.getLogs(), | ||
}; | ||
} catch (error) { | ||
return { | ||
_success: false, | ||
message: error.message, | ||
debugUrl, | ||
sessionUrl, | ||
logs: logger.getLogs(), | ||
}; | ||
} finally { | ||
await stagehand.close(); | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { EvalFunction } from "@/types/evals"; | ||
import { z } from "zod"; | ||
|
||
export const apple_tv: EvalFunction = async ({ | ||
debugUrl, | ||
sessionUrl, | ||
stagehand, | ||
logger, | ||
agent, | ||
}) => { | ||
try { | ||
await stagehand.page.goto("https://www.apple.com/"); | ||
|
||
const agentResult = await agent.execute({ | ||
instruction: | ||
"Identify the size and weight for the Apple TV 4K and list the Siri Remote features introduced.", | ||
maxSteps: 30, | ||
}); | ||
|
||
const { height, width } = await stagehand.page.extract({ | ||
modelName: "google/gemini-2.5-flash", | ||
instruction: "Extract the size and weight of the Apple TV 4K", | ||
schema: z.object({ | ||
height: z.number().describe("The height of the Apple TV 4K in inches"), | ||
width: z.number().describe("The width of the Apple TV 4K in inches"), | ||
}), | ||
}); | ||
|
||
const success = | ||
agentResult.success && | ||
height === 1.2 && | ||
width === 3.66 && | ||
stagehand.page.url().includes("https://www.apple.com/apple-tv-4k/specs/"); | ||
|
||
if (!success) { | ||
return { | ||
_success: false, | ||
message: agentResult.message, | ||
debugUrl, | ||
sessionUrl, | ||
logs: logger.getLogs(), | ||
}; | ||
} | ||
return { | ||
_success: true, | ||
debugUrl, | ||
sessionUrl, | ||
logs: logger.getLogs(), | ||
}; | ||
} catch (error) { | ||
return { | ||
_success: false, | ||
message: error.message, | ||
debugUrl, | ||
sessionUrl, | ||
logs: logger.getLogs(), | ||
}; | ||
} finally { | ||
await stagehand.close(); | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//agent often fails on this one, | ||
import { EvalFunction } from "@/types/evals"; | ||
import { z } from "zod"; | ||
export const arxiv_gpt_report: EvalFunction = async ({ | ||
debugUrl, | ||
sessionUrl, | ||
stagehand, | ||
logger, | ||
agent, | ||
}) => { | ||
try { | ||
await stagehand.page.goto("https://arxiv.org/"); | ||
|
||
const agentResult = await agent.execute({ | ||
instruction: | ||
"Find the paper 'GPT-4 Technical Report', when was v3 submitted?", | ||
maxSteps: 20, | ||
}); | ||
|
||
// Mon, 27 Mar 2023 17:46:54 UTC | ||
const { date } = await stagehand.page.extract({ | ||
modelName: "google/gemini-2.5-flash", | ||
instruction: | ||
"Extract the date of the v3 submission history, it should be in the format 'MM-DD-YYYY'", | ||
schema: z.object({ | ||
date: z.string().describe("The date of the v3 submission history"), | ||
}), | ||
}); | ||
|
||
console.log(`date: ${date}`); | ||
|
||
const success = agentResult.success && date === "03-27-2023"; | ||
|
||
if (!success) { | ||
return { | ||
_success: false, | ||
message: agentResult.message, | ||
debugUrl, | ||
sessionUrl, | ||
logs: logger.getLogs(), | ||
}; | ||
} | ||
return { | ||
_success: true, | ||
debugUrl, | ||
sessionUrl, | ||
logs: logger.getLogs(), | ||
}; | ||
} catch (error) { | ||
return { | ||
_success: false, | ||
message: error.message, | ||
debugUrl, | ||
sessionUrl, | ||
logs: logger.getLogs(), | ||
}; | ||
} finally { | ||
await stagehand.close(); | ||
} | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.