Skip to content

Conversation

@cuiyuebing
Copy link
Member

AgentScope Version

[The version of AgentScope you are working on, e.g. import agentscope; print(agentscope.__version__)]

Description

[Please describe the background, purpose, changes made, and how to test this PR]

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with pre-commit run --all-files command
  • All tests are passing
  • Docstrings are in Google style
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@DavdGao DavdGao requested a review from Copilot September 2, 2025 03:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the browser-use agent example with significant improvements to functionality and structure. The changes enhance the agent's task decomposition capabilities, add structured output support, and improve the overall architecture.

  • Replaces hardcoded prompts with external markdown files for better maintainability
  • Adds task decomposition functionality to break complex tasks into manageable subtasks
  • Introduces structured output support using Pydantic models

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
examples/agent_browser/main.py Updates agent configuration, adds structured output model, and fixes grammar in documentation
examples/agent_browser/build_in_prompt/browser_agent_task_decomposition_prompt.md New prompt template for decomposing browser automation tasks into subtasks
examples/agent_browser/build_in_prompt/browser_agent_sys_prompt.md New system prompt defining the browser agent's behavior and guidelines
examples/agent_browser/build_in_prompt/browser_agent_summarize_task.md New prompt template for generating comprehensive task summary reports
examples/agent_browser/build_in_prompt/browser_agent_reasoning_prompt.md New reasoning prompt for chunk-based webpage analysis
examples/agent_browser/browser_agent.py Major refactor adding task decomposition, chunk-based observation, structured output, and multimodal support

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +30 to +35
with open(
"examples/agent_browser/build_in_prompt/browser_agent_sys_prompt.md",
"r",
encoding="utf-8",
) as f:
_BROWSER_AGENT_DEFAULT_SYS_PROMPT = f.read()
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded file paths make the code fragile and dependent on the current working directory. Consider using os.path.dirname(__file__) or pathlib.Path(__file__).parent to construct relative paths from the current module's location.

Copilot uses AI. Check for mistakes.
) as f:
_BROWSER_AGENT_DEFAULT_REASONING_PROMPT = f.read()
with open(
"examples/agent_browser/build_in_prompt/browser_agent_task_decomposition_prompt.md", # noqa: E501 pylint: disable=C0301
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using both noqa and pylint disable comments for the same line length issue is redundant. Choose one consistent approach throughout the codebase.

Suggested change
"examples/agent_browser/build_in_prompt/browser_agent_task_decomposition_prompt.md", # noqa: E501 pylint: disable=C0301
"examples/agent_browser/build_in_prompt/browser_agent_task_decomposition_prompt.md", # pylint: disable=C0301

Copilot uses AI. Check for mistakes.
self.iter_n = 0
self.finish_function_name = "browser_generate_final_response"
self.init_query = ""
self._required_structured_model: Type[BaseModel] | None = None
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Optional[Type[BaseModel]] instead of Type[BaseModel] | None for better compatibility with older Python versions and consistency with other type hints in the codebase.

Suggested change
self._required_structured_model: Type[BaseModel] | None = None
self._required_structured_model: Optional[Type[BaseModel]] = None

Copilot uses AI. Check for mistakes.
text = re.sub(r"```yaml.*?```", "", text, flags=re.DOTALL)
# Remove JavaScript code blocks
text = re.sub(r"```js.*?```", "", text, flags=re.DOTALL)
# # Remove JavaScript code blocks
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commented-out code should be removed entirely rather than left as a comment. If the functionality might be needed later, consider documenting the reason for removal or create a proper TODO comment.

Suggested change
# # Remove JavaScript code blocks

Copilot uses AI. Check for mistakes.
for i in range(0, len(snapshot_str), max_length)
]

def observe_by_chunk(self, image_path: str | None = "") -> Msg:
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Optional[str] instead of str | None for consistency with other type hints in the codebase, and consider using None as the default value instead of an empty string for an optional parameter.

Suggested change
def observe_by_chunk(self, image_path: str | None = "") -> Msg:
def observe_by_chunk(self, image_path: Optional[str] = None) -> Msg:

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Dec 2, 2025

This PR is marked as stale because there has been no activity for 30 days. Remove stale label or add new comments or this PR will be closed in 5 day.

@cla-assistant
Copy link

cla-assistant bot commented Dec 2, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ TCtower
❌ cuiyuebing
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot removed the stale-pr label Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants