Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,33 @@
from connectonion import Agent
from connectonion.useful_plugins import image_result_formatter, ui_stream

from tools.web_automation import web
from tools.browser import web
from tools.deep_research import perform_deep_research

# Load environment variables
load_dotenv()

# Create the agent
system_prompt_path = Path(__file__).parent / "prompts" / "agent.md"
def create_agent():
"""Create a fresh browser agent instance.

agent = Agent(
name="browser_agent",
model=os.getenv("BROWSER_AGENT_MODEL", "co/gemini-2.5-flash"),
system_prompt=system_prompt_path,
# We pass the web instance (for direct tools) AND the deep_research function
tools=[web, perform_deep_research],
plugins=[image_result_formatter, ui_stream],
max_iterations=50
)
Returns a new Agent instance for each request to ensure proper isolation.
Used by host() to create agents per request.
"""
system_prompt_path = Path(__file__).parent / "prompts" / "agent.md"

return Agent(
name="browser_agent",
model="co/gemini-2.5-pro",
system_prompt=system_prompt_path,
tools=[web, perform_deep_research],
plugins=[image_result_formatter, ui_stream],
max_iterations=200
)

if __name__ == "__main__":
agent = create_agent()
agent.input("""pls use this user name and passwd to login nsw.gov.au aaronplus1996@gmail.com passwd is @HZERn5W65z$-Ez
the url is https://driver-knowledge-test.service.nsw.gov.au/
then try to click and learning all the learning part
if any page need auth code, pls let use to use login thing to login
""")
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"""
import os
from connectonion import host
from agent import agent
from agent import create_agent

if __name__ == "__main__":
trust = os.environ.get("TRUST", "open") # Default to open for local dev
print(f"Starting browser-agent with trust={trust}")
print("WebSocket endpoint: ws://localhost:8000/ws")
print("HTTP endpoint: http://localhost:8000/input")
host(agent, trust=trust, relay_url=None) # Disable relay for local testing
host(create_agent, trust=trust, relay_url=None) # Disable relay for local testing
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ pydantic>=2.0.0
typer>=0.9.0
rich>=13.0.0
Pillow
textual>=0.60.0
Loading