-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[STG-1045] Add logging at all 4 levels: agent.execute, agent.act/observe/extract, CLICK/HOVER/SCROLL, and CDP #1283
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?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
69404e7 to
a58f549
Compare
- Add SessionFileLogger class that writes to session-specific directories
- Read BROWSERBASE_CONFIG_DIR from env (defaults to ./.browserbase)
- Create session directory structure: {configDir}/sessions/{sessionId}/
- Create convenience symlink: {configDir}/sessions/latest
- Write to 5 separate log files:
- session.json (sanitized V3Options with secrets masked)
- agent_events.log (TASK level - agent.execute)
- stagehand_events.log (STEP level - act/observe/extract)
- understudy_events.log (ACTION level - CLICK/HOVER/etc)
- cdp_events.log (CDP MSG level)
- All filesystem operations are async, non-blocking, and fail silently
- Logs still also written to stdout via v3Logger for backwards compatibility
- Add .browserbase/ to .gitignore
- Update flowLoggingJourney example to show session log directory
Co-authored-by: Nick Sweeting <pirate@users.noreply.github.com>
…nt ids, cleanup code
This comment was marked as resolved.
This comment was marked as resolved.
| const llmRequestId = uuidv7(); | ||
| SessionFileLogger.logLlmRequest({ | ||
| requestId: llmRequestId, | ||
| model: this.modelName, |
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.
note for the future, we might want to keep track of other params (non-sensitive) in model based on the ModelConfiguration type
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.
note for compactness we can also store the default model config in sessions/{id}/session.json dir, and then only add extra to the individual loglines if they are different from the session-wide defaults.
| // ============================================================================= | ||
| // Types | ||
| // ============================================================================= |
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.
These are okay because this file is a stepping stone so keeping them here to accelerate implementation, will move to types dir once stable
| // ============================================================================= | ||
| // Formatting Utilities (used by pretty streams) | ||
| // ============================================================================= |
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.
Same with these, will eventually move to utils
miguelg719
left a comment
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.
🚢🚢🚢
Co-authored-by: Miguel <36487034+miguelg719@users.noreply.github.com>
why
Clarify where the execution flow goes when stagehand runs by showing more detailed logs.
what changed
Adds a log line printed at the beginning and end of each layer's execution:
Log lines are written to
./.browserbase/sessions/{sessionId}/{agent,stagehand,understudy,cdp}.logat runtime, and can be followed in a single unified screen by doing:tail -f ./.browserbase/sessions/latest/*.logtest plan
Test by running:
flowLoggingJourney.ts:EXPECTED OUTPUT: