Agent S: an open agentic framework that uses computers like a human
| Files | Last commit | Last update |
|---|---|---|
| 11 months ago | ||
| 1 year ago | ||
| 4 months ago | ||
| 8 months ago | ||
| 6 months ago | ||
| 11 months ago | ||
| 7 months ago | ||
| 1 year ago | ||
| 1 year ago | ||
| 8 months ago | ||
| 1 year ago | ||
| 1 year ago | ||
| 1 year ago | ||
| 7 months ago |

🏆 Agent S3:首个在 OSWorld 上超越人类表现(72.60%)
🌐 [S2 博客] 📄 [S2 论文 (COLM 2025)] 🎥 [S2 视频]
🌐 [S1 博客] 📄 [S1 论文 (ICLR 2025)] 🎥 [S1 视频]
不想繁琐配置?在 Simular Cloud 中试用 Agent S
🥳 更新动态
目录
💡 简介
欢迎使用 Agent S,这是一个开源框架,旨在通过智能体-计算机接口实现与计算机的自主交互。我们的使命是构建能够从过往经验中学习并在您的计算机上自主执行复杂任务的智能 GUI 智能体。
无论您是对人工智能、自动化感兴趣,还是希望为前沿的智能体系统贡献力量,我们都很高兴您能加入!
🎯 当前成果
在 OSWorld 上,仅使用 Agent S3 在 100 步设置中就达到了 66% 的成功率,已经超过了之前 63.4% 的最先进水平(GTA1 搭配 GPT-5)。通过添加行为最佳选择(Behavior Best-of-N),性能进一步提升至 72.6%,超越了人类在 OSWorld 上的表现水平(约 72%)!
Agent S3 还展现出强大的零样本泛化能力!在 WindowsAgentArena 上,仅使用 Agent S3 时准确率为 50.2%,而通过从 3 次推演中选择,准确率提升至 56.6%。同样,在 AndroidWorld 上,性能从 68.1% 提高到 71.6%。
🛠️ 安装与设置
前提条件
- 单显示器:我们的智能体设计适用于单显示器屏幕
- 安全性:智能体通过运行 Python 代码来控制您的计算机 - 请谨慎使用
- 支持的平台:Linux、Mac 和 Windows
安装
若要无需克隆仓库安装 Agent S3,请运行
pip install gui-agents
如果您希望在进行更改的同时测试 Agent S3,请克隆存储库并使用以下命令安装
pip install -e .
别忘了还要执行 brew install tesseract!Pytesseract 需要额外安装这个才能正常工作。
API 配置
选项 1:环境变量
添加到你的 .bashrc(Linux)或 .zshrc(MacOS)中:
export OPENAI_API_KEY=<YOUR_API_KEY>
export ANTHROPIC_API_KEY=<YOUR_ANTHROPIC_API_KEY>
export HF_TOKEN=<YOUR_HF_TOKEN>
选项 2:Python 脚本
import os
os.environ["OPENAI_API_KEY"] = "<YOUR_API_KEY>"
支持的模型
我们支持 Azure OpenAI、Anthropic、Gemini、Open Router 和 vLLM 推理。详情请参见 models.md。
基础模型(必需)
为获得最佳性能,我们建议使用托管在 Hugging Face Inference Endpoints 或其他提供商处的 UI-TARS-1.5-7B。设置说明请参见 Hugging Face Inference Endpoints。
🚀 使用方法
⚡️ 推荐配置:
为获得最佳配置,我们建议使用 OpenAI gpt-5-2025-08-07 作为主模型,并搭配 UI-TARS-1.5-7B 作为基础模型。
命令行界面(CLI)
请注意,这是在运行我们改进后的 Agent S3,不含 bBoN。
使用所需参数运行 Agent S3:
agent_s \
--provider openai \
--model gpt-5-2025-08-07 \
--ground_provider huggingface \
--ground_url http://localhost:8080 \
--ground_model ui-tars-1.5-7b \
--grounding_width 1920 \
--grounding_height 1080
本地编码环境(可选)
对于需要代码执行的任务(例如数据处理、文件操作、系统自动化),您可以启用本地编码环境:
agent_s \
--provider openai \
--model gpt-5-2025-08-07 \
--ground_provider huggingface \
--ground_url http://localhost:8080 \
--ground_model ui-tars-1.5-7b \
--grounding_width 1920 \
--grounding_height 1080 \
--enable_local_env
⚠️ 警告:本地编码环境会在您的机器上本地执行任意 Python 和 Bash 代码。仅在可信环境中并使用可信输入时才使用此功能。
必要参数
--provider:主生成模型提供商(例如 openai、anthropic 等)- 默认值:"openai"--model:主生成模型名称(例如 gpt-5-2025-08-07)- 默认值:"gpt-5-2025-08-07"--ground_provider:基础模型提供商 - 必填--ground_url:基础模型的 URL - 必填--ground_model:基础模型名称 - 必填--grounding_width:基础模型输出坐标分辨率的宽度 - 必填--grounding_height:基础模型输出坐标分辨率的高度 - 必填
可选参数
--model_temperature:所有模型调用的固定温度值(对于 o3 等模型需要设置为 1.0,其他模型可留空)
基础模型分辨率
基础模型的宽度和高度应与其输出坐标分辨率相匹配:
- UI-TARS-1.5-7B:使用
--grounding_width 1920 --grounding_height 1080 - UI-TARS-72B:使用
--grounding_width 1000 --grounding_height 1000
可选参数
--model_url:主生成模型的自定义 API URL - 默认值:""--model_api_key:主生成模型的 API 密钥 - 默认值:""--ground_api_key:基础模型端点的 API 密钥 - 默认值:""--max_trajectory_length:轨迹中保留的最大图像轮次数量 - 默认值:8--enable_reflection:启用反思代理以协助工作代理 - 默认值:True--enable_local_env:启用本地编码环境以执行代码(警告:会本地执行任意代码)- 默认值:False
本地编码环境详情
本地编码环境使 Agent S3 能够直接在您的机器上执行 Python 和 Bash 代码。这对于以下场景特别有用:
- 数据处理:操作电子表格、CSV 文件或数据库
- 文件操作:批量文件处理、内容提取或文件整理
- 系统自动化:配置更改、系统设置或自动化脚本
- 代码开发:编写、编辑或执行代码文件
- 文本处理:文档操作、内容编辑或格式化
启用后,代理可以使用 call_code_agent 操作来执行代码块,以完成可通过编程而非 GUI 交互完成的任务。
要求:
- Python:运行 Agent S3 所使用的 Python 解释器(会自动检测)
- Bash:位于
/bin/bash(在 macOS 和 Linux 上为标准配置) - 系统权限:代理以执行它的用户的相同权限运行
安全注意事项:
- 本地环境会以运行代理的用户的相同权限执行任意代码
- 仅在可信环境中启用此功能
- 当代理生成系统级操作代码时要格外谨慎
- 对于不可信任务,考虑在沙盒环境中运行
- Bash 脚本的执行超时时间为 30 秒,以防止进程挂起
gui_agents SDK
首先,我们导入必要的模块。AgentS3 是 Agent S3 的主智能体类。OSWorldACI 是我们的基础智能体,负责将智能体操作转换为可执行的 Python 代码。
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 # Optional: for local coding environment
# Load in your API keys.
from dotenv import load_dotenv
load_dotenv()
current_platform = "linux" # "darwin", "windows"
接下来,我们定义引擎参数。engine_params 用于主智能体,engine_params_for_grounding 用于事实依据获取。对于 engine_params_for_grounding,我们支持自定义端点,例如 HuggingFace TGI、vLLM 和 Open Router。
engine_params = {
"engine_type": provider,
"model": model,
"base_url": model_url, # Optional
"api_key": model_api_key, # Optional
"temperature": model_temperature # Optional
}
# Load the grounding engine from a custom endpoint
ground_provider = "<your_ground_provider>"
ground_url = "<your_ground_url>"
ground_model = "<your_ground_model>"
ground_api_key = "<your_ground_api_key>"
# Set grounding dimensions based on your model's output coordinate resolution
# UI-TARS-1.5-7B: grounding_width=1920, grounding_height=1080
# UI-TARS-72B: grounding_width=1000, grounding_height=1000
grounding_width = 1920 # Width of output coordinate resolution
grounding_height = 1080 # Height of output coordinate resolution
engine_params_for_grounding = {
"engine_type": ground_provider,
"model": ground_model,
"base_url": ground_url,
"api_key": ground_api_key, # Optional
"grounding_width": grounding_width,
"grounding_height": grounding_height,
}
然后,我们定义了基础代理和 Agent S3。
# Optional: Enable local coding environment
enable_local_env = False # Set to True to enable local code execution
local_env = LocalEnv() if enable_local_env else None
grounding_agent = OSWorldACI(
env=local_env, # Pass local_env for code execution capability
platform=current_platform,
engine_params_for_generation=engine_params,
engine_params_for_grounding=engine_params_for_grounding,
width=1920, # Optional: screen width
height=1080 # Optional: screen height
)
agent = AgentS3(
engine_params,
grounding_agent,
platform=current_platform,
max_trajectory_length=8, # Optional: maximum image turns to keep
enable_reflection=True # Optional: enable reflection agent
)
最后,让我们查询智能体!
# Get screenshot.
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)
exec(action[0])
有关推理循环工作原理的更多详情,请参阅 gui_agents/s3/cli_app.py。
OSWorld
要在 OSWorld 中部署 Agent S3,请遵循 OSWorld 部署说明。
💬 引用
如果您发现此代码库有用,请引用:
@misc{Agent-S3,
title={The Unreasonable Effectiveness of Scaling Agents for Computer Use},
author={Gonzalo Gonzalez-Pumariega and Vincent Tu and Chih-Lun Lee and Jiachen Yang and Ang Li and Xin Eric Wang},
year={2025},
eprint={2510.02250},
archivePrefix={arXiv},
primaryClass={cs.AI},
url={https://arxiv.org/abs/2510.02250},
}
@misc{Agent-S2,
title={Agent S2: A Compositional Generalist-Specialist Framework for Computer Use Agents},
author={Saaket Agashe and Kyle Wong and Vincent Tu and Jiachen Yang and Ang Li and Xin Eric Wang},
year={2025},
eprint={2504.00906},
archivePrefix={arXiv},
primaryClass={cs.AI},
url={https://arxiv.org/abs/2504.00906},
}
@inproceedings{Agent-S,
title={{Agent S: An Open Agentic Framework that Uses Computers Like a Human}},
author={Saaket Agashe and Jiuzhou Han and Shuyu Gan and Jiachen Yang and Ang Li and Xin Eric Wang},
booktitle={International Conference on Learning Representations (ICLR)},
year={2025},
url={https://arxiv.org/abs/2410.08164}
}