` tag) containing the text "text".
- [6] `text
` → Mark 6 is a division (`` tag) containing the text "text" and is scrollable.
- [7] `
text | ` → Mark 7 is a table cell (`` tag) containing the text "text".
Note that these text snippets may be incomplete.
## History
You will see your past actions and observations but not old annotated webpages.
This means annotated webpages showing useful information will not be visible in future actions.
To get around this, key details from each webpage are stored in observations.
## Web Browser Actions
You can only take the following actions with the web browser:
{tool_descriptions}
## Important Browsing Tips
If there is a modal overlay that is unresponsive on the page try reloading the webpage.
If there is a cookie consent form covering part of the page just click accept on the form.
When typing into a text field be sure to click one of the dropdown options (when present). Not selecting a dropdown option will result in the field being cleared after the next action.
You do not have access any internet accounts (outside of those provided by the user).
The browser has a built in CAPTCHA solver, if you are asked to solve one just wait and it will be solved for you.
## Don't Repeat the Same Actions Continuously
If you find yourself repeating an action without making progress, try another action.
## Task
You will now be connected to the user, who will give you their task.""" # noqa: E501
MAX_MESSAGES_FOR_CONTEXT_WINDOW = {
MessageLabel.SCREENSHOT: 1,
# MessageLabel.REASONING_INDUCTION: 1,
# MessageLabel.FORMAT_INSTRUCTIONS: 1,
# MessageLabel.ACTION: 1,
}
@Agents.register_agent_config("browser")
class BrowserAgentConfig(BaseAgentConfig):
name: Literal["browser"] = "browser"
history_messages_limit: dict[MessageLabel, int] = Field(
default_factory=lambda: MAX_MESSAGES_FOR_CONTEXT_WINDOW,
)
@Agents.register_agent("browser")
class BrowserAgent(BaseAgent):
config: BrowserAgentConfig
message_label: MessageLabel = MessageLabel.AGENT_MODEL_RESPONSE
def __init__(self, **data):
super().__init__(**data)
@property
def system_prompt(self) -> str:
return BROWSER_AGENT_SYSTEM_PROMPT.format(
date_time_with_day=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
tool_descriptions=self.tool_descriptions,
memories="",
)
@cached_property
def tools(self) -> list[Tool]:
return self.env_tools
async def get_history_view(self) -> MessageHistory:
return MessageHistory(
messages=[SystemMessage(content=[Text(text=self.system_prompt)])],
) + self.history.history_view(
limits=self.config.history_messages_limit,
)
|