Skip to main content

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: 0.11(950.11 (95% savings from 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:
Agent Selection:
Global State Management:
Multi-Agent Execution:
Task Completion Analysis:

2. Agent Loop (agent/loop.py)

The core conversation engine with Claude API: Sampling Loop:
API Provider Support: Beta Flags:
  • prompt-caching-2024-07-31 - 90% cost reduction on cached tokens
  • advanced-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
System Prompt Initialization:

3. Tool System (agent/tools/)

Tool Hierarchy:
Tool Versions: ToolCollection API:

Advanced Capabilities

4. Subagent System (agent/subagent.py)

Implements Anthropic’s sub-agent compression pattern for 95% context savings: Subagent Types: Architecture:
Usage:

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)
Preset Servers:
Usage in sampling_loop:

6. Structured Output (agent/structured_output.py)

Force Claude to return valid JSON matching specified schemas: Pre-defined Schemas:
  • TICKET_ANALYSIS_SCHEMA - Support ticket analysis
  • TASK_RESULT_SCHEMA - Task completion results
  • CODE_ANALYSIS_SCHEMA - Code review findings
  • ENTITY_EXTRACTION_SCHEMA - Entity extraction
Usage:

Optimization Systems

7. Parallel Executor (agent/parallel_executor.py)

Automatic parallel execution for independent tool calls: Dependency Analysis:
Execution Strategy:

8. Context Optimizer (agent/context_optimizer.py)

Implements 5 Anthropic context engineering patterns: Pattern 1: Just-in-Time Retrieval
Pattern 2: Dynamic Compaction
Pattern 3: Structured Note-Taking
Pattern 4: Sub-Agent Compression
Pattern 5: Attention Budget Monitoring

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
Speed Modes:

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)
Recovery Strategies:

Observability System

11. Unified Observability (agent/observability/)

Single interface for all observability concerns: Configuration:
Usage:
Components: 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:
Health States:
  • HEALTHY - All checks passing
  • DEGRADED - Some checks failing, system operational
  • UNHEALTHY - Critical failures

Dashboard Architecture

15. Backend (dashboard/backend/)

FastAPI REST API with async operations:
Key Technologies:
  • 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:
Key Technologies:
  • 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

  1. Define AgentConfig in AGENT_CONFIGS
  2. Add keyword detection in get_active_agents()
  3. Create completion indicators in analyze_task_completion()

Adding New Tools

  1. Inherit from BaseAnthropicTool
  2. Implement __call__ returning ToolResult
  3. Add to version groups in agent/tools/groups.py
  4. 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.