StateSet Computer Use Agent
AI that operates your software — a virtual employee. Computer Use automates the legacy tools that have no API at all. Where RPA encodes pixel positions and breaks when a button moves, these agents perceive the screen and reason about it, adapting the way a person would.Executive Summary
StateSet Computer Use Agent is a production-grade AI automation platform powered by Claude Opus 4.5. The system deploys multiple specialized AI agents that can see, understand, and interact with desktop environments to complete complex, long-running tasks autonomously. Built with Python using async/await patterns throughout, the platform implements Anthropic’s context engineering research achieving 95% cost savings compared to naive approaches. Key Metrics:- Average tokens/task: 7,500 (95% reduction from 150k baseline)
- Average cost/task: 2.25 baseline)
- Average task duration: 30 seconds (33% faster with parallel execution)
- Parallel speedup: 30-50% on multi-tool tasks
System Architecture Diagram
Core Components
1. Main Orchestrator (main.py)
The entry point for all agent execution, responsible for:
Environment Validation:
2. Agent Loop (agent/loop.py)
The core conversation engine with Claude API:
Sampling Loop:
Beta Flags:
prompt-caching-2024-07-31- 90% cost reduction on cached tokensadvanced-tool-use-2025-11-20- Tool search (regex/bm25)effort-2025-11-24- Effort parameter (low/medium/high)computer-use-2025-11-24- Latest tool version with zoom action
3. Tool System (agent/tools/)
Tool Hierarchy:
ToolCollection API:
Advanced Capabilities
4. Subagent System (agent/subagent.py)
Implements Anthropic’s sub-agent compression pattern for 95% context savings:
Subagent Types:
Architecture:
5. MCP Client Integration (agent/mcp_client.py)
Connect to external Model Context Protocol servers:
Supported Transports:
- STDIO (subprocess)
- SSE (Server-Sent Events)
- HTTP (direct HTTP)
6. Structured Output (agent/structured_output.py)
Force Claude to return valid JSON matching specified schemas:
Pre-defined Schemas:
TICKET_ANALYSIS_SCHEMA- Support ticket analysisTASK_RESULT_SCHEMA- Task completion resultsCODE_ANALYSIS_SCHEMA- Code review findingsENTITY_EXTRACTION_SCHEMA- Entity extraction
Optimization Systems
7. Parallel Executor (agent/parallel_executor.py)
Automatic parallel execution for independent tool calls:
Dependency Analysis:
8. Context Optimizer (agent/context_optimizer.py)
Implements 5 Anthropic context engineering patterns:
Pattern 1: Just-in-Time Retrieval
9. Tool Execution Guard (agent/tool_guard.py)
Safety and verification layer:
Features:
- Pre-execution Validation: Safety checks before tool execution
- Visual Verification: Confirms actions took effect (optional)
- Stuck Detection: Monitors for infinite loops
- Result Caching: 120-second TTL for cacheable operations
10. Stuck Detection (agent/stuck_detection.py)
Prevents infinite loops and stuck patterns:
Detection Methods:
- Repeating same action consecutively
- Cycling between 2-3 actions
- No visual progress (identical screenshots)
- Slow progress (too few actions per time)
Observability System
11. Unified Observability (agent/observability/)
Single interface for all observability concerns:
Configuration:
Environment Variables:
Infrastructure
12. Configuration Management (agent/config.py)
Centralized configuration with documented rationale:
Configuration Classes:
13. Exception Hierarchy (agent/exceptions.py)
Comprehensive error handling:
14. Health Monitoring (agent/health.py)
Production health checks:
HEALTHY- All checks passingDEGRADED- Some checks failing, system operationalUNHEALTHY- Critical failures
Dashboard Architecture
15. Backend (dashboard/backend/)
FastAPI REST API with async operations:
- FastAPI with CORS
- SQLAlchemy async ORM
- PostgreSQL database
- Celery task queue
- Server-Sent Events (SSE)
- S3-compatible artifact storage (boto3)
16. Frontend (dashboard/frontend/)
Next.js 14 application:
- Next.js 14 with app router
- React Query for data fetching
- Tailwind CSS styling
- EventSource for real-time updates
Execution Flow
Complete Request Flow
Agent Types
Supported Agents
Agent Configuration
Security Architecture
API Key Management
- All keys via environment variables
- Validation on startup
- No key transmission to external services
Tool Safety
- Directory traversal prevention in EditTool
- Prompt injection protection in MemoryTool
- Pre-execution validation via ToolExecutionGuard
- Agent memory isolation (per agent_id)
Sandbox Execution
- Tools run in controlled environment
- File system access limited by permissions
- Network access controlled by system
Performance Characteristics
Benchmarks
Cost Breakdown
File Organization
Extension Points
Adding New Agents
- Define AgentConfig in
AGENT_CONFIGS - Add keyword detection in
get_active_agents() - Create completion indicators in
analyze_task_completion()
Adding New Tools
- Inherit from
BaseAnthropicTool - Implement
__call__returningToolResult - Add to version groups in
agent/tools/groups.py - Update tool traits if cacheable/read-only
Adding MCP Servers
Quick Reference
Environment Variables
Common Commands
This architecture provides a scalable, maintainable foundation for computer use automation with AI agents, implementing production-grade patterns for reliability, observability, and cost optimization.