To integrate Agent S3 into your own Python applications, use the gui_agents SDK. The workflow involves defining engine parameters for both the main model and the grounding model, initializing an OSWorldACI grounding agent, and then creating an AgentS3 instance.
Core Components
AgentS3: The main agent class.OSWorldACI: The grounding agent that translates actions into executable Python code.LocalEnv: (Optional) Enables the local coding environment.
Implementation Steps
- Define
engine_params for the main model (provider, model, base_url, api_key, temperature). - Define
engine_params_for_grounding for the grounding model (engine_type, model, base_url, api_key, grounding_width, grounding_height). - Initialize
OSWorldACI with the engine parameters and platform. - Initialize
AgentS3 with the grounding agent and platform. - Call
agent.predict(instruction, observation) where observation is a dictionary containing a screenshot (as bytes).
import pyautogui
import io
from gui_agents.s3.agents.agent_s import AgentS3
from gui_agents.s3.agents.grounding import OSWorldACI
from gui_agents.s3.utils.local_env import LocalEnv
from dotenv import load_dotenv
load_dotenv()
# 1. Setup Parameters
current_platform = "linux" # "darwin", "windows"
engine_params = {
"engine_type": "openai",
"model": "gpt-5-2025-08-07",
"api_key": "YOUR_API_KEY"
}
engine_params_for_grounding = {
"engine_type": "huggingface",
"model": "ui-tars-1.5-7b",
"base_url": "http://localhost:8080",
"grounding_width": 1920,
"grounding_height": 1080,
}
# 2. Initialize Agents
enable_local_env = False
local_env = LocalEnv() if enable_local_env else None
grounding_agent = OSWorldACI(
env=local_env,
platform=current_platform,
engine_params_for_generation=engine_params,
engine_params_for_grounding=engine_params_for_grounding,
width=1920,
height=1080
)
agent = AgentS3(
engine_params,
grounding_agent,
platform=current_platform,
max_trajectory_length=8,
enable_reflection=True
)
# 3. Run Inference
screenshot = pyautogui.screenshot()
buffered = io.BytesIO()
screenshot.save(buffered, format="PNG")
screenshot_bytes = buffered.getvalue()
obs = {
"screenshot": screenshot_bytes,
}
instruction = "Close VS Code"
info, action = agent.predict(instruction=instruction, observation=obs)
# Execute the returned action
exec(action[0])