Skip to content

Add OpenClaw environment type#402

Open
zkwentz wants to merge 1 commit intometa-pytorch:mainfrom
zkwentz:feature/openclaw-env
Open

Add OpenClaw environment type#402
zkwentz wants to merge 1 commit intometa-pytorch:mainfrom
zkwentz:feature/openclaw-env

Conversation

@zkwentz
Copy link
Contributor

@zkwentz zkwentz commented Feb 21, 2026

Summary

Adds a new OpenClaw environment type following the MCP (Model Context Protocol) pattern.

Features

  • 8 tools: exec, read, write, edit, web_search, web_fetch, memory_search, memory_get
  • Full test suite (17 tests passing)
  • Docker support via workflow integration
  • Follows echo_env reference implementation pattern

Tools

Tool Description
exec Execute shell commands
read Read file contents
write Write files
edit Edit files with search/replace
web_search Search the web (simulated in sandbox)
web_fetch Fetch URL content (simulated in sandbox)
memory_search Semantic memory search
memory_get Retrieve memory snippets

Testing

cd tests/envs
pytest test_openclaw_environment.py -v

Related

This PR adds a new OpenClaw environment that exposes agentic tool capabilities
for reinforcement learning training. OpenClaw is a personal AI assistant framework
that provides agents with access to:

- File system operations (read, write, edit)
- Shell command execution (exec)
- Web research tools (web_search, web_fetch)
- Memory/context management (memory_search, memory_get)

The environment wraps these capabilities as MCP (Model Context Protocol) tools,
enabling RL agents to learn real-world agentic workflows like coding, research,
and automation tasks.

Features:
- Full MCP tool integration following the OpenEnv patterns
- Isolated workspace per episode for safe exploration
- Sandbox mode for web tools (simulated results)
- Comprehensive test suite
- Docker support with CI integration

Usage:
```python
from openclaw_env import OpenClawEnv

with OpenClawEnv(base_url="http://localhost:8000") as env:
    env.reset()
    tools = env.list_tools()
    result = env.call_tool("exec", command="echo hello")
```
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 21, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 21, 2026

Greptile Summary

Adds a new OpenClaw environment following the MCP (Model Context Protocol) pattern established in RFC 003. The implementation provides 8 tools for agentic RL training: file operations (read/write/edit), shell execution (exec), web tools (web_search/web_fetch - simulated in sandbox), and memory management (memory_search/memory_get).

Key Changes:

  • Environment server (openclaw_environment.py) extends MCPEnvironment with inline FastMCP tool definitions
  • Client (client.py) is a simple wrapper of MCPToolClient for OpenClaw-specific usage
  • Comprehensive test suite with 17 tests covering all tools, edge cases, and episode isolation
  • Docker integration added to CI/CD workflow
  • Per-episode workspace isolation using temp directories
  • Follows echo_env reference implementation pattern

Architecture Alignment:

  • Correctly implements dual API boundary (MCP tools for agents, Gym API for infrastructure)
  • No client-server separation violations
  • Agents cannot access reset/simulation controls (only exposed via infrastructure API)
  • Shell execution uses shell=True which is acceptable given workspace sandboxing

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Clean implementation following established patterns; no invariant violations; comprehensive test coverage; proper isolation and security controls; no Tier 1 issues found
  • No files require special attention

Important Files Changed

Filename Overview
envs/openclaw_env/server/openclaw_environment.py Implements OpenClaw environment with 8 MCP tools; follows MCPEnvironment pattern correctly; shell execution uses shell=True which is acceptable in sandboxed context
envs/openclaw_env/client.py Simple client wrapper extending MCPToolClient; no client-server separation violations; follows echo_env pattern
envs/openclaw_env/server/app.py FastAPI app creation follows standard pattern; correctly uses create_app with MCP types
tests/envs/test_openclaw_environment.py Comprehensive test suite with 17 tests covering all tools, edge cases, and episode isolation
envs/openclaw_env/server/Dockerfile Proper Docker setup with system dependencies, workspace isolation, and health check

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Agent] -->|ListToolsAction| B[OpenClawEnvironment]
    A -->|CallToolAction| B
    
    B --> C{Tool Router}
    
    C -->|exec| D[Shell Execution]
    C -->|read/write/edit| E[File Operations]
    C -->|web_search/web_fetch| F[Web Tools - Simulated]
    C -->|memory_search/memory_get| G[Memory Management]
    
    D --> H[Workspace Sandbox]
    E --> H
    G --> H
    
    H -->|Observation| A
    F -->|Observation| A
    
    I[Infrastructure] -->|reset| B
    I -->|state| B
    
    B -->|Creates per episode| H
    
    style H fill:#e1f5ff
    style A fill:#fff4e1
    style I fill:#ffe1f5
    style B fill:#e1ffe1
Loading

Last reviewed commit: 984320c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant