Skip to content

Add session metadata for model name if env: BROWSERBASE #765

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
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

kamath
Copy link
Member

@kamath kamath commented May 16, 2025

why

Be able to show users what model config they used in the Browserbase dashboard

what changed

Just added session create metadata to send modelName to the Browserbase API similar to stagehand: true on Browserbase session create

test plan

Added new evals

Copy link

changeset-bot bot commented May 16, 2025

🦋 Changeset detected

Latest commit: 3e9579c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kamath kamath changed the title add session metadata for model name Add session metadata for model name if env: BROWSERBASE May 16, 2025
@kamath kamath marked this pull request as ready for review May 16, 2025 22:52
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Added session metadata tracking for model names and custom client usage in Browserbase sessions, with corresponding test coverage and configuration updates.

  • Added modelName and usingCustomClient metadata in lib/index.ts for Browserbase session creation
  • Added test custom_client_metadata.test.ts to verify metadata with custom LLM clients
  • Updated sessions.test.ts to verify standard model metadata tracking
  • Changed default model from gpt-4o to google/gemini-2.0-flash in stagehand.config.ts
  • Added development tooling with example-dev.ts and corresponding npm scripts

8 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +23 to +26
modelName: undefined,
llmClient: new AISdkClient({
model: google("gemini-2.0-flash"),
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Setting modelName to undefined while providing an llmClient with a specific model (gemini-2.0-flash) seems inconsistent. Consider setting modelName to match the provided model or document why this is intentionally different.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is intentional to mock when users don't provide a modelName

Comment on lines +42 to +44
expect(session.userMetadata.stagehand).toBe("true");
expect(session.userMetadata.modelName).toBe("NO_MODEL_DEFINED");
expect(session.userMetadata.usingCustomClient).toBe("true");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Values in userMetadata are stored as strings ('true', 'NO_MODEL_DEFINED'). Consider using a type-safe enum or constants for these values to prevent typos and ensure consistency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k

@kamath kamath marked this pull request as draft May 16, 2025 22:59
kamath and others added 7 commits May 16, 2025 16:22
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@kamath kamath marked this pull request as ready for review May 16, 2025 23:37
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

(updates since last review)

Reverted model configuration from Gemini back to GPT-4o and cleaned up development files.

  • Changed model configuration in stagehand.config.ts from google/gemini-2.0-flash back to gpt-4o
  • Updated sessions.test.ts to verify GPT-4o metadata instead of Gemini
  • Removed development files example-dev.ts and related npm scripts
  • Fixed _usingCustomClient logic in lib/index.ts to correctly identify custom client usage

6 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -739,6 +744,8 @@ export class Stagehand {
this.env,
this.headless,
this.logger,
this._usingCustomClient ? "NO_MODEL_DEFINED" : this.modelName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using a constant for 'NO_MODEL_DEFINED' to avoid magic strings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants