-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Standardize eval policy, budgets, session metadata, traces, and cost accounting #2902
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
miguelg719
wants to merge
12
commits into
evals/consolidation-11-verifier-results
Choose a base branch
from
evals/consolidation-12-shared-runner-contract
base: evals/consolidation-11-verifier-results
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.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0510620
Cleanup
miguelg719 87796a0
Merge branch 'evals/consolidation-11-verifier-results' into evals/con…
miguelg719 50ecddd
Merge branch 'evals/consolidation-11-verifier-results' into evals/con…
miguelg719 533dff0
Merge branch 'evals/consolidation-11-verifier-results' into evals/con…
miguelg719 5796ed5
Merge branch 'evals/consolidation-11-verifier-results' into evals/con…
miguelg719 6ecc3d0
fix(evals): tighten shared runner reporting and accounting
miguelg719 5e739f7
Merge branch 'evals/consolidation-11-verifier-results' into evals/con…
miguelg719 207a17d
Merge branch 'evals/consolidation-11-verifier-results' into evals/con…
miguelg719 3f5ea51
Merge branch 'evals/consolidation-11-verifier-results' into evals/con…
miguelg719 794fa18
Merge commit '94080eb4250cf4b507df142baf10a41509706bf8' into HEAD
miguelg719 e5c1759
Merge commit 'a08cec74dcc87cd81724785c46c898a7111f3004' into HEAD
miguelg719 8f03f33
Merge commit '2136ac456525120b5be5620af986747dbc6107d6' into HEAD
miguelg719 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
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,89 @@ | ||
| import type { LogLine } from "stagehand-v3"; | ||
| import type { TaskResult } from "./types.js"; | ||
|
|
||
| export const BROWSER_SESSION_LOG_CATEGORY = "session"; | ||
|
|
||
| /** Where the browser behind a run lives, resolved before the agent starts. */ | ||
| export interface BrowserSessionInfo { | ||
| provider: "browserbase" | "local"; | ||
| sessionId?: string; | ||
| sessionUrl?: string; | ||
| debugUrl?: string; | ||
| } | ||
|
|
||
| export function browserbaseSessionUrl(sessionId: string): string { | ||
| return `https://www.browserbase.com/sessions/${encodeURIComponent(sessionId)}`; | ||
| } | ||
|
|
||
| /** | ||
| * Read the session fields core tools and runner-provided targets publish on | ||
| * their `metadata` (`browserbaseSessionId` / `browserbaseSessionUrl` / | ||
| * `browserbaseDebugUrl`). Falls back to the bare provider when a Browserbase | ||
| * surface does not report its session id (browse_cli). | ||
| */ | ||
| export function browserSessionFromMetadata( | ||
| metadata: Record<string, unknown> | undefined, | ||
| environment: "LOCAL" | "BROWSERBASE", | ||
| ): BrowserSessionInfo { | ||
| if (environment !== "BROWSERBASE") return { provider: "local" }; | ||
| const rawUrl = readString(metadata?.browserbaseSessionUrl); | ||
| const sessionId = | ||
| readString(metadata?.browserbaseSessionId) ?? rawUrl?.match(/\/sessions\/([^/?#]+)/u)?.[1]; | ||
| const sessionUrl = rawUrl ?? (sessionId ? browserbaseSessionUrl(sessionId) : undefined); | ||
| const debugUrl = readString(metadata?.browserbaseDebugUrl); | ||
| return { | ||
| provider: "browserbase", | ||
| ...(sessionId && { sessionId }), | ||
| ...(sessionUrl && { sessionUrl }), | ||
| ...(debugUrl && { debugUrl }), | ||
| }; | ||
| } | ||
|
|
||
| export function formatBrowserSessionMessage(info: BrowserSessionInfo): string { | ||
| if (info.provider === "local") return "Browser: local"; | ||
| if (!info.sessionUrl) return "Browser: browserbase (session id not reported by this surface)"; | ||
| return `Browserbase session: ${info.sessionUrl}`; | ||
| } | ||
|
|
||
| /** Level-0 lines so the session pointer survives every log filter. */ | ||
| export function buildBrowserSessionLogLines(info: BrowserSessionInfo): LogLine[] { | ||
| const lines: LogLine[] = [ | ||
| { | ||
| category: BROWSER_SESSION_LOG_CATEGORY, | ||
| level: 0, | ||
| message: formatBrowserSessionMessage(info), | ||
| auxiliary: { | ||
| provider: { value: info.provider, type: "string" }, | ||
| ...(info.sessionId && { sessionId: { value: info.sessionId, type: "string" } }), | ||
| ...(info.sessionUrl && { sessionUrl: { value: info.sessionUrl, type: "string" } }), | ||
| }, | ||
| }, | ||
| ]; | ||
| if (info.debugUrl) { | ||
| lines.push({ | ||
| category: BROWSER_SESSION_LOG_CATEGORY, | ||
| level: 0, | ||
| message: `Browserbase debugger: ${info.debugUrl}`, | ||
| }); | ||
| } | ||
| return lines; | ||
| } | ||
|
|
||
| export function logBrowserSession(sink: { log(line: LogLine): void }, info: BrowserSessionInfo) { | ||
| for (const line of buildBrowserSessionLogLines(info)) sink.log(line); | ||
| } | ||
|
|
||
| /** Surface the session on the TaskResult row so Braintrust output is filterable. */ | ||
| export function withBrowserSession(result: TaskResult, info: BrowserSessionInfo): TaskResult { | ||
| return { | ||
| ...result, | ||
| browserProvider: info.provider, | ||
| ...(info.sessionId && { browserbaseSessionId: info.sessionId }), | ||
| ...(info.sessionUrl && { sessionUrl: result.sessionUrl || info.sessionUrl }), | ||
| ...(info.debugUrl && { debugUrl: result.debugUrl || info.debugUrl }), | ||
| }; | ||
| } | ||
|
|
||
| function readString(value: unknown): string | undefined { | ||
| return typeof value === "string" && value.trim() ? value : undefined; | ||
| } |
Oops, something went wrong.
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.