Skip to main content
The Workspace component abstracts execution environments for agent operations. It provides a unified interface for command execution and file operations across local processes, containers, and remote servers. Source: openhands/sdk/workspace/

Core Responsibilities

The Workspace system has four primary responsibilities:
  1. Execution Abstraction - Unified interface for command execution across environments
  2. File Operations - Upload, download, and manipulate files in workspace
  3. Resource Management - Context manager protocol for setup/teardown
  4. Environment Isolation - Separate agent execution from host system

Architecture

Key Components

Workspace Types

Local vs Remote Execution

Core Operations

Command Execution

Command Result Structure:

File Operations

Resource Management

Workspaces use context manager for safe resource handling: Lifecycle Hooks:

Remote Workspace Extensions

The SDK provides remote workspace implementations in openhands-workspace package: Implementation Comparison: Source:

Component Relationships

How Workspace Integrates

Relationship Characteristics:
  • Conversation → Workspace: Conversation factory uses workspace type to select LocalConversation or RemoteConversation
  • Workspace → Agent Server: RemoteWorkspace delegates operations to agent-server API
  • Tools Independence: Tools run in the same environment as workspace

See Also