-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Recover bounded capture deadlines and preserve terminal session loss #2893
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
5
commits into
evals/consolidation-11-verifier-results
Choose a base branch
from
evals/consolidation-03-capture-recovery
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
5 commits
Select commit
Hold shift + click to select a range
6de29db
Reorder #2893: add capture recovery after verifier results
miguelg719 8c19da7
Merge commit 'ad027817aa9edd5b409557b1349e87b84d78762c' into HEAD
miguelg719 d23d757
Merge commit 'e0f2b1ee1bef756576d7d52136ac242e2c68826e' into HEAD
miguelg719 6cdab01
Merge commit '3c36966aa285f8630ffd4a26c6bf8285dd3dcd2a' into HEAD
miguelg719 2bc5787
Merge commit 'af1cf703925647db722d166cafc75bcfbe3f36df' 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@browserbasehq/stagehand": patch | ||
| --- | ||
|
|
||
| Bound experimental batch and RPC deadlines so callers can stop waiting without replaying actions or accepting late capture state. |
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
70 changes: 70 additions & 0 deletions
70
packages/evals/tests/core/browserSessionLossTelemetry.test.ts
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,70 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| parseSessionLossTelemetry, | ||
| SESSION_LOST_TELEMETRY_PREFIX, | ||
| } from "../../core/tools/browserSessionLoss.js"; | ||
|
|
||
| function line(fields: Record<string, unknown>) { | ||
| return ( | ||
| SESSION_LOST_TELEMETRY_PREFIX + JSON.stringify({ cause: "CDP connection closed", ...fields }) | ||
| ); | ||
| } | ||
|
|
||
| describe("facade session loss diagnostics", () => { | ||
| it("retains browser identity, measured age and configured timeout", () => { | ||
| expect( | ||
| parseSessionLossTelemetry( | ||
| line({ | ||
| tool: "snapshot", | ||
| at: "2026-09-08T00:00:00.000Z", | ||
| provider: "browserbase", | ||
| sessionId: "session-123", | ||
| sessionAgeMs: 12_500, | ||
| sessionTimeoutMs: 3_600_000, | ||
| }), | ||
| ), | ||
| ).toEqual({ | ||
| cause: "CDP connection closed", | ||
| tool: "snapshot", | ||
| at: "2026-09-08T00:00:00.000Z", | ||
| provider: "browserbase", | ||
| sessionId: "session-123", | ||
| sessionAgeMs: 12_500, | ||
| sessionTimeoutMs: 3_600_000, | ||
| }); | ||
| }); | ||
|
|
||
| it.each([-1, "12000", null, {}, 1e309])("drops invalid diagnostic durations: %j", (value) => { | ||
| expect( | ||
| parseSessionLossTelemetry(line({ sessionAgeMs: value, sessionTimeoutMs: value })), | ||
| ).toEqual({ cause: "CDP connection closed" }); | ||
| }); | ||
|
|
||
| it("accepts zero age and omits invalid identity metadata", () => { | ||
| expect( | ||
| parseSessionLossTelemetry(line({ provider: "other", sessionId: 42, sessionAgeMs: 0 })), | ||
| ).toEqual({ cause: "CDP connection closed", sessionAgeMs: 0 }); | ||
| }); | ||
|
|
||
| it("drops JSON numeric overflow without losing the terminal cause", () => { | ||
| expect( | ||
| parseSessionLossTelemetry( | ||
| SESSION_LOST_TELEMETRY_PREFIX + | ||
| '{"cause":"CDP connection closed","sessionAgeMs":1e309,"sessionTimeoutMs":1e309}', | ||
| ), | ||
| ).toEqual({ cause: "CDP connection closed" }); | ||
| }); | ||
|
|
||
| it("sanitizes string diagnostics while retaining valid numeric metadata", () => { | ||
| const parsed = parseSessionLossTelemetry( | ||
| line({ | ||
| provider: "local", | ||
| sessionId: "wss://example.test/?apiKey=synthetic-key", | ||
| sessionAgeMs: 1, | ||
| }), | ||
| ); | ||
| expect(parsed?.provider).toBe("local"); | ||
| expect(parsed?.sessionAgeMs).toBe(1); | ||
| expect(JSON.stringify(parsed)).not.toContain("synthetic-key"); | ||
| }); | ||
| }); | ||
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
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.