-
Notifications
You must be signed in to change notification settings - Fork 62
Adding a simple debug agent to manually test actions #237
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
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.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
Category | Issue | Status |
---|---|---|
Redundant Commented Code ▹ view | ||
Unsanitized User Input in Action Handling ▹ view | ||
Overcomplicated String Assignment ▹ view | ||
Redundant Observation Processing ▹ view | ||
Silent AttributeError Suppression ▹ view |
Files scanned
File Path | Reviewed |
---|---|
src/agentlab/agents/debug_agent.py | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
|
||
def get_action(self, obs): | ||
|
||
# print(obs["pruned_html"]) |
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.
Redundant Commented Code 
Tell me more
What is the issue?
Commented-out code that adds noise without value
Why this matters
Commented code creates uncertainty about whether it should be preserved and makes the code harder to maintain.
Suggested change ∙ Feature Preview
Remove the commented line entirely
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
src/agentlab/agents/debug_agent.py
Outdated
|
||
# print(obs["pruned_html"]) | ||
print("\n") | ||
action = input(obs["axtree_txt"] + "\n") |
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.
Unsanitized User Input in Action Handling 
Tell me more
What is the issue?
Raw input from user is accepted without any validation or sanitization in the get_action method
Why this matters
Malicious input could be injected that manipulates the action handling or triggers unexpected behavior. The input is directly used as an action without bounds checking or sanitization.
Suggested change ∙ Feature Preview
def get_action(self, obs):
raw_action = input(obs["axtree_txt"] + "\n")
# Validate input matches expected action format
if raw_action not in self.action_set.valid_actions:
raise ValueError("Invalid action provided")
action = raw_action
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
|
||
def __post_init__(self): | ||
try: # some attributes might be temporarily args.CrossProd for hyperparameter generation | ||
self.agent_name = f"debug".replace("/", "_") |
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.
Overcomplicated String Assignment 
Tell me more
What is the issue?
Unnecessary f-string and string manipulation for a static string
Why this matters
The code is overly complex for a simple string assignment. The f-string serves no purpose as there's no interpolation, and replace() is called on a string that can't contain '/'.
Suggested change ∙ Feature Preview
self.agent_name = "debug"
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
def obs_preprocessor(self, obs): | ||
obs = deepcopy(obs) | ||
obs["dom_txt"] = flatten_dom_to_str( | ||
obs["dom_object"], | ||
extra_properties=obs["extra_element_properties"], | ||
with_visible=True, | ||
with_clickable=True, | ||
with_center_coords=True, | ||
with_bounding_box_coords=True, | ||
filter_visible_only=False, | ||
filter_with_bid_only=False, | ||
filter_som_only=False, | ||
) | ||
obs["axtree_txt"] = flatten_axtree_to_str( | ||
obs["axtree_object"], | ||
extra_properties=obs["extra_element_properties"], | ||
with_visible=True, | ||
with_clickable=True, | ||
with_center_coords=True, | ||
with_bounding_box_coords=True, | ||
filter_visible_only=False, | ||
filter_with_bid_only=False, | ||
filter_som_only=False, | ||
) | ||
obs["pruned_html"] = prune_html(obs["dom_txt"]) | ||
obs["screenshot_som"] = overlay_som( |
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.
Redundant Observation Processing 
Tell me more
What is the issue?
The obs_preprocessor performs multiple expensive operations on every observation, including a deep copy of the entire observation and multiple string conversions, without any caching.
Why this matters
For debugging purposes, this creates unnecessary overhead as these transformations are recomputed even when the DOM hasn't changed, potentially slowing down the debugging process especially with rapid interactions.
Suggested change ∙ Feature Preview
Implement caching of processed observations based on a hash of the input DOM/axtree to avoid reprocessing identical states. Only process what's needed for the current debugging context. Example:
def obs_preprocessor(self, obs):
# Only process what's actually being used in get_action
obs = obs.copy() # shallow copy is sufficient
obs['axtree_txt'] = flatten_axtree_to_str(
obs['axtree_object'],
extra_properties=obs['extra_element_properties'],
with_visible=True,
with_clickable=True,
with_center_coords=True,
with_bounding_box_coords=True,
filter_visible_only=False,
filter_with_bid_only=False,
filter_som_only=False,
)
return obs
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
try: # some attributes might be temporarily args.CrossProd for hyperparameter generation | ||
self.agent_name = f"debug".replace("/", "_") | ||
except AttributeError: | ||
pass |
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.
Silent AttributeError Suppression 
Tell me more
What is the issue?
Silent failure with empty except block that masks AttributeError without any logging or information preservation
Why this matters
When an AttributeError occurs, silently ignoring it makes debugging difficult as there's no way to know what caused the error or if it occurred at all
Suggested change ∙ Feature Preview
Add logging to capture the error information:
import logging
try:
self.agent_name = f"debug".replace("/", "_")
except AttributeError as e:
logging.debug(f"Skipping agent_name assignment during hyperparameter generation: {e}")
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
Description by Korbit AI
What change is being made?
Add a new debug agent in
debug_agent.py
for manual testing of actions within the browser gym environment.Why are these changes being made?
This change introduces a tool to facilitate the manual testing of actions, providing a way to interactively verify and debug the system's behavior using the
DebugAgent
, which outputs a text representation of the observation and takes input for actions. This supports developers in quickly testing environments without relying solely on automated frameworks.