-
Notifications
You must be signed in to change notification settings - Fork 85
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
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 | ||
Silent AttributeError Suppression ▹ view | ||
Redundant Observation Processing ▹ view | 🧠 Not in standard |
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( |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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 simple debug agent,
DebugAgent
, and its associated arguments class,DebugAgentArgs
, to manually test actions within the agentlab framework.Why are these changes being made?
These changes introduce a mechanism to help developers manually explore and test agent behaviors by inputting actions based on observations flattened from DOM and accessibility trees. This approach allows for increased flexibility and insight during the development and debugging of agent actions, which is difficult to achieve with automated testing alone.