Skip to content
yusf1013Public

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

SpecOps

Fully automated testing framework for GUI-based AI agents in real-world environments. Given a feature list and an agent specification, SpecOps generates test cases, sets up the environment, executes the agent, and validates the results — producing a bug report with no human in the loop.

Paper: SpecOps: A Fully Automated AI Agent Testing Framework in Real-World GUI Environments ICSE '26 — Rio de Janeiro, Brazil

Motivation

AI agents that operate computers — browsing the web, managing files, sending emails — are increasingly capable but poorly tested. In a manual red-teaming study, we found that every agent we tested had functional bugs: emails sent to wrong recipients, files silently overwritten, commands run in the wrong directory. These aren't edge cases — they're core features failing quietly, all with potentially severe real-world consequences.

Manual testing doesn't scale. Each test requires careful planning, setting up the test environment, feeding the agent a task, monitoring its execution in real time, and validating output — a tedious and labor intensive process. SpecOps automates the entire pipeline. In our evaluation, it found 164 true bugs across 5 agents with an F1 score of 0.89 at under $0.73 per test. See the paper for full results.

Architecture

SpecOps decomposes testing into four specialized phases, each handled by distinct LLM-based specialist agents:

  1. Phase 1 — Test Case Generation (test_spec_gen.py): A dual-specialist approach where the Test Architect generates structured test cases (environment setup, natural-language prompts, expected behaviors) and the Test Analyst reviews them for feasibility, prompt completeness, and oracle generalizability.
  2. Phase 2 — Environment Setup (main.py): The Infrastructure Manager specialist translates high-level setup requirements into concrete tool invocations, populating realistic test environments (e.g., sending seed emails, creating files). It uses an adaptive strategy to refine test specifications based on actual setup outcomes.
  3. Phase 3 — Test Execution (main.py): The Engineer Specialist launches and interacts with the subject agent via universal UI primitives (keyboard/mouse), using human-like visual monitoring through screen captures to record the agent's behavior.
  4. Phase 4 — Validation & Auditing (main.py): The Investigator Specialist independently probes the environment for changes, while the Judge analyzes all evidence (screenshots, observer commentary, investigator report) using Meta Chain-of-Thought prompting to produce a final bug report.

SpecOps Architecture

Examples

The examples/ directory contains annotated end-to-end runs with test specifications, execution logs, and screenshots. Each example walks through what was tested, what went wrong, and how SpecOps caught it.

  • Missing Subject Line and Unresolved Placeholder — Proxy AI sends an email with no subject and a literal "[Your Name]" placeholder, then reports everything went fine. The Investigator Specialist navigates Gmail's Sent folder to reveal both bugs.

  • Off-by-One Insertion Error — Open Interpreter confuses 1-based line numbers with 0-based list indices, inserting text at the wrong line and falsely reporting success. The Investigator Specialist catches it from the runtime screenshots and independently reading the file.

Project Structure

├── test_spec_gen.py           # Phase 1: Test Architect + Test Analyst
├── main.py                    # Phases 2-4: Infrastructure Manager, Engineer, Investigator, Judge
├── converse.py                # LLM call abstraction (Bedrock Converse API)
├── bedrock_client.py          # AWS Bedrock client + model constants
├── operate.py                 # Tool execution loop, JSON extraction
├── image_processor.py         # Multimodal report generation (Phase 4 Judge)
├── tool_schemas.py            # Bedrock tool definitions
├── screen_utils.py            # pyautogui-based GUI tools (Engineer Specialist)
├── setup_utils.py             # Email/file/terminal tools (Infrastructure Manager)
├── screen_recorder.py         # ffmpeg x11grab screen recorder
├── inputs/
│   ├── features/              # Feature lists per domain (JSON arrays)
│   ├── subject_agent_metadata/ # Agent specification JSONs
│   └── assets/                # Reference files (e.g., HR policy docs)
├── outputs/
│   └── test_cases/            # Generated test case JSONs
└── examples/                  # Annotated end-to-end examples with screenshots

Prerequisites

  • Python 3.10+
  • Linux desktop environment (X11) for Phases 2-4
  • AWS credentials configured with access to Amazon Bedrock (Claude models) in us-east-1
  • ffmpeg (for screen recording in Phase 3)

Setup

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

If you only need Phase 1 (test case generation), the core dependencies are:

pip install boto3 pillow tqdm

Environment variables

Create a .env file in the project root:

# User identity (used in prompts and email setup)
USER_NAME=YourName
GMAIL_EMAIL=your_test_gmail@gmail.com

# Required for email domain testing (Phase 2)
MAILTRAP_USER=your_mailtrap_username
MAILTRAP_PASSWORD=your_mailtrap_password
EMAIL_SENDER_DOMAIN=@yourdomain.com  

# Required for Phases 2-4 if agent sends email
GMAIL_APP_PASSWORD=your_app_password

Quick Start — Phase 1

Phase 1 is the most accessible starting point. It requires only AWS Bedrock access and generates test cases without needing a GUI environment.

source .venv/bin/activate

# Generate test cases for Open Interpreter (file system domain)
python test_spec_gen.py \
    inputs/features/file_system.json \
    inputs/subject_agent_metadata/OI.json \
    outputs/test_cases/file_system \
    --verbose

# Generate for a subset of features
python test_spec_gen.py \
    inputs/features/email.json \
    inputs/subject_agent_metadata/proxy.json \
    outputs/test_cases/email \
    --ids 1 4

# Generate HR test cases (attaches policy docs automatically)
python test_spec_gen.py \
    inputs/features/hr.json \
    inputs/subject_agent_metadata/hr.json \
    outputs/test_cases/HR_QnA \
    --verbose

Output format

Each generated test case is a JSON file:

{
    "feature_id": 3,
    "test_case_id": 1,
    "test_case_name": "Find File in Nested Directories",
    "feature_description": "Locate a specific file by its name",
    "env_setup": "rm -rf ~/Desktop/oi/*\nmkdir -p ~/Desktop/oi/documents/work/...",
    "prompt": "I need to find my file called project_timeline.docx. Can you search for it?",
    "expected_behaviour": "The agent searches through directories and reports finding...",
    "env_probing_required": "no"
}
  • env_setup: Concrete environment state that must exist before the agent runs.
  • prompt: Natural-language instruction given to the subject agent.
  • expected_behaviour: What correct agent behavior looks like (used as the oracle in Phase 4).
  • env_probing_required: "yes" if validation requires the Investigator Specialist to independently probe the environment (e.g., checking sent emails, verifying file contents).

Running Phases 2-4

Phases 2-4 require a Linux desktop (X11), the subject agent installed and running on the same machine, and a display for screen recording.

Step 1: Install the subject agent

Agent Domain Install Status
Open Interpreter File System pip install open-interpreter Ready to test
Autonomous HR Chatbot HR Q&A See repo README Ready to test
TaxyAI Email Chrome extension Ready to test
Self-Operating Computer Email pip install self-operating-computer Ready to test
Proxy AI Email Web app Offline (acquired by Salesforce)

Step 2: Review agent metadata

The test_execution section in each agent's JSON file (the Agent Specification) contains the instructions that the Engineer Specialist follows to launch, operate, and reset the subject agent. Review and update these to match your local setup — for example, your conda environment name, install path, or browser configuration may differ from the defaults.

Key fields to check:

  • test_setup: How the Engineer Specialist launches the agent (e.g., interpreter -y for OI, python -m operate.main for SOC)
  • cleanup: How to reset between test runs (e.g., references conda env oi by name — change if yours is different)
  • working_directory: Where terminal-based agents operate (e.g., ~/Desktop/oi)

See Agent Specification Configuration for the full schema.

Step 3: Prepare the UI

The Engineer Specialist interacts via screenshots and GUI automation, so the correct windows must be open and visible before starting.

Agent UI Setup
Open Interpreter Open a terminal, activate its conda/venv environment, and leave the terminal visible. The Engineer Specialist will launch interpreter itself via test_setup.
Self-Operating Computer Open a terminal, activate its conda/venv environment, and have a browser window with fresh tabs open alongside it
TaxyAI Open a browser with the TaxyAI extension installed and 3 fresh tabs open
HR Chatbot Start the chatbot server (streamlit run app.py), open a browser to localhost:8501 with 3 fresh tabs
Proxy AI (Offline — was browser-based, required a browser with fresh tabs)

For CLI-based agents (Open Interpreter, Self-Operating Computer), ensure all dependencies are installed and the correct conda/venv environment is activated in the terminal before starting.

Step 4: Run

# Run all phases for a set of test cases
python main.py \
    outputs/test_cases/file_system \
    inputs/subject_agent_metadata/OI.json

# Run only Phase 2 (environment setup)
python main.py \
    outputs/test_cases/file_system \
    inputs/subject_agent_metadata/OI.json \
    --phase 2

# Run specific test cases by feature ID
python main.py \
    outputs/test_cases/file_system \
    inputs/subject_agent_metadata/OI.json \
    --ids 3 6

Agent Specification Configuration

Each subject agent is described by a JSON file (the Agent Specification) with three sections:

{
    "agent": { ... },
    "test_execution": { ... },
    "test_generation": { ... }
}

agent — Agent identity (used across all phases)

{
    "agent": {
        "overview": "What this agent is and does",
        "interaction_protocol": "How a user interacts with it (browser, CLI, etc.)",
        "agent_capabilities": "Scope of abilities",
        "tool_name": "Display name",
        "setup_tools": "email | terminal (tools for the Infrastructure Manager in Phase 2)",
        "investigation_mode": "gui | terminal (how the Investigator Specialist probes the environment in Phase 4)",
        "domain": "Gmail (natural-language domain name, used in Investigator prompts)",
        "domain_url": "mail.google.com (URL the GUI Investigator navigates to)"
    }
}

test_execution — How to run tests (Phases 2-4)

{
    "test_execution": {
        "test_setup": "Step-by-step instructions for the Engineer Specialist to launch the agent",
        "working_directory": "~/Desktop/oi (for terminal-based agents)",
        "additional_instructions": "Hints for the Engineer Specialist during execution",
        "cleanup": "Instructions to reset between test runs"
    }
}

test_generation — Phase 1 configuration (optional but recommended)

{
    "test_generation": {
        "examples": [
            "Example 1:\nTask: ...\na) setup: ...\nb) prompt: ...\nc) expected output: ..."
        ],
        "env_setup_instructions": "Guidance for the Test Architect on how to write env_setup values",
        "files": {
            "description": "Description of attached files",
            "files": ["path/to/doc1.pdf", "path/to/doc2.txt"]
        }
    }
}
  • examples: Domain-specific few-shot examples that guide the Test Architect to produce high-quality test cases.
  • env_setup_instructions: Constraints and guidance for environment setup (e.g., "only terminal commands", "must use ~/Desktop/oi").
  • files: Reference documents attached to the LLM call (e.g., HR policy docs, database exports) so the Test Architect can generate test cases with realistic, concrete data.

Adding Your Own Agent

  1. Create a feature list at inputs/features/your_domain.json:

    [
        {"id": 1, "task": "Short task name", "description": "What the agent should do"},
        {"id": 2, "task": "Another task", "description": "More detail"}
    ]
  2. Create an Agent Specification at inputs/subject_agent_metadata/your_agent.json with at minimum agent and test_execution sections (see configuration above). Decide which tools the Infrastructure Manager needs for environment setup (setup_tools: email, terminal, or both) and how the Investigator Specialist should probe the environment after execution (investigation_mode: gui for UI navigation, terminal for CLI access). For read-only domains with no environment probing, both fields can be omitted.

  3. Generate test cases:

    python test_spec_gen.py \
        inputs/features/your_domain.json \
        inputs/subject_agent_metadata/your_agent.json \
        outputs/test_cases/YourAgent_run1
  4. Run Phases 2-4 (requires the subject agent accessible on the machine):

    python main.py \
        outputs/test_cases/YourAgent_run1 \
        inputs/subject_agent_metadata/your_agent.json

Email Setup

Email domain tests (e.g., TaxyAI, Self-Operating Computer) require the Infrastructure Manager to populate the user's Gmail inbox with realistic seed emails from varied senders before the subject agent runs. Since SpecOps tests agents on real-world applications like Gmail, there is no API to directly inject messages into the inbox — emails must actually be delivered. To send as arbitrary addresses like boss@yourdomain.com or hr@yourdomain.com, you need an SMTP relay with a custom sending domain.

We use Mailtrap for this:

  1. Sign up at mailtrap.io
  2. Add and verify a custom sending domain (e.g., yourdomain.com) — this is what allows sending from any *@yourdomain.com address
  3. Set the SMTP credentials and domain in .env:
    MAILTRAP_USER=your_mailtrap_username
    MAILTRAP_PASSWORD=your_mailtrap_password
    EMAIL_SENDER_DOMAIN=@yourdomain.com

If you prefer a different SMTP provider or email injection method, the relevant function is add_email_in_inbox in setup_utils.py.

Citation

If you use SpecOps in your research, please cite:

@inproceedings{ahmed2026specops,
  title={SpecOps: A Fully Automated AI Agent Testing Framework in Real-World GUI Environments},
  author={Ahmed, Syed Yusuf and Feng, Shiwei and Bae, Chanwoo and Barrus, Calix and Zhang, Xiangyu},
  booktitle={2026 IEEE/ACM 48th International Conference on Software Engineering (ICSE)},
  year={2026},
  doi={10.1145/3744916.3787778}
}

License

This work is licensed under a Creative Commons Attribution 4.0 International License.

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages