-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Bug Description
When using Stagehand V3 with verbose: 0, debug-level logs like DEBUG: xpath main-world are still printed to the console. The v3Logger function has a fallback path that bypasses verbose level filtering.
Steps to Reproduce
import { Stagehand } from "@browserbasehq/stagehand";
const stagehand = new Stagehand({
env: "LOCAL",
verbose: 0, // Errors only
disablePino: true,
});
await stagehand.init();
const page = stagehand.context.pages()[0];
await page.goto("https://example.com");
// Use any locator/xpath operation
await page.locator("//div").first();Expected Behavior
With verbose: 0, only error-level logs should be printed. Debug logs should be suppressed.
Actual Behavior
Debug logs are printed:
[2026-01-02T13:16:37.661Z] DEBUG: xpath main-world
frameId: F6611B8D017F9801E6E83A956066C58D
xp: /html/body[1]/div[1]/div[3]/main[1]/div[1]/div[2]/form[1]/div[1]/input[2]
ctxId: 3
Root Cause Analysis
In lib/v3/logger.ts, the v3Logger function has two code paths:
- Instance logger path (lines ~500-510): Calls the registered instance logger which respects verbose level
- Fallback path (lines ~514-540): Directly logs to console without checking verbose level
The fallback path logs to console regardless of configured verbosity:
if (lvl === 2) {
(console.debug ?? console.log)(output); // No verbose check!
}Meanwhile, StagehandLogger.log() correctly checks: if (logLine.level > this.verbose) return;
Suggested Fix
The fallback path in v3Logger should either:
- Not log at all when no instance logger is registered (let it be silent)
- Or check against a global/default verbose level before logging
Environment
- Stagehand version: latest (V3)
- Node.js version: 22
- OS: Alpine Linux (Docker) / macOS
Metadata
Metadata
Assignees
Labels
No labels