-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Allow configuring Stagehand's cache directory #1091
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
base: main
Are you sure you want to change the base?
Allow configuring Stagehand's cache directory #1091
Conversation
# why solves browserbase#1060 patch regression of playwright arguments being removed from agent execute response # what changed agent.execute now returns playwright arguments in its response # test plan tested locally
…ms to docs (browserbase#1065) # why reflect project id changes in docs # what changed advanced configuration comments # test plan reviewed via mintlify on localhost
# why Easier to use for Custom LLM Clients and keep users up to date with our aisdk file # what changed added export of aisdk to lib/index.ts # test plan build local stagehand, import local AISdkClient, run Azure Stagehand session
…onfigu… (browserbase#1073) …ration settings # why Updated docs to match the new fingerprint params in the Browserbase docs here: https://docs.browserbase.com/guides/stealth-customization#customization-options # what changed Update browser configuration docs to reflect the docs changes. # test plan
# why Updating docs to reflect aisdk can be imported directly # what changed The model page # test plan Reviewed page with mintlify dev locally
# why # what changed # test plan
# why Currently, we do not support stagehand agent within the api # what changed When api is enabled, stagehand agent now routes through the api # test plan Tested locally
# why Currently, using playwright screenshot command is not available when the execution environment is Stagehand. A customer has indicated they would prefer to use Playwright's native screenshot command instead of CDP when using Browserbase as CDP screenshot causes unexpected behavior for their target site. # what changed - added a StagehandScreenshotOptions type with useCDP argument added - extended page type to accept custom stagehand screeenshot options - update screenshot proxy to default useCDP to true if the env is browserbase and use playwright screenshot if false - added eval for screenshot with and without cdp # test plan - tested and confirmed functionality with eval and external example script (not committed)
…rowserbase#1057) # why We want to build a best in class agent in stagehand. Therefore, we need more eval benchmarks. # what changed - Added Web-bench evals dataset - Added a subset of OS World evals - those that can be run in a chrome browser (desktop-based tasks omitted) - added LICENSE noticed to the copied evals tasks - Added ground truth / expected result to some WebVoyager tasks using reference_answer.json from Browser Use public evals repo. Improvements to `pnpm run evals -man` to better describe how to run evals. # test plan Evals should run locally and bb for these new benchmarks.
# why Initial instructions didn't mention uv or pip prerequisites and also didn't mention venv. Fix reduces friction on first timers. # what changed - added link to install uv - added details for initializing venv - adjusted code example respectively # test plan docs change
# why - webpage structure changed, needed to update the xpath in the expected locator
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR adds configurable cache directory support to Stagehand, addressing issue #190. The implementation allows users to specify a custom cache directory via the cacheDir constructor option or the STAGEHAND_CACHE_DIR environment variable, with fallback to the default <cwd>/tmp/.cache path.
Key changes:
- Added
cacheDirparameter toConstructorParamsinterface with proper JSDoc documentation - Updated
BaseCacheconstructor to accept optionalcacheDirparameter and resolve it through environment variables - Modified
LLMProviderto pass cache directory configuration toLLMCache - Updated documentation in
caching.mdxto explain the new configuration options - Added comprehensive test coverage for cache directory resolution logic
- Refactored agent tools to use
StagehandPageinstead of fullStagehandobject for better separation of concerns
Architecture improvements:
- Better path resolution handling with absolute path detection
- Environment variable precedence: constructor param > env var > default
- Test coverage ensures cache directory creation respects configuration
Confidence score: 4/5
- This PR is safe to merge with minor improvements recommended
- The implementation correctly addresses the user requirement for configurable cache directories. The code follows existing patterns, includes proper documentation, and has test coverage. Minor logic improvements suggested for edge case handling and code simplification.
- lib/cache/BaseCache.ts requires minor fix for whitespace-only path handling
6 files reviewed, 2 comments
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>
|
@seanmcguire12 all good! |
Let folks point the cache at a writable path via the new cacheDir option or STAGEHAND_CACHE_DIR, document it, and cover the behavior with regression tests.
Covers #190