Design Principles
1. Language-Agnostic
ORS uses HTTP, making it implementable in any programming language:- Python, TypeScript, Go, Rust, Java, etc.
- Any web framework or HTTP library
- Standard REST patterns
2. Episode-Centric
The protocol is organized around RL episodes (sessions):- One session = one episode
- Episode continues until
finished: true - Stateful interaction across multiple tool calls
3. Tool-Based Interaction
All agent actions are tool calls:- Discovered via
GET /{env_name}/tools - Executed via
POST /{env_name}/call - Return structured outputs with rewards
Protocol Architecture
Key Components
Agent Side:- Makes HTTP requests
- Parses SSE responses
- Maintains session ID
- Implements HTTP endpoints
- Manages episode state
- Executes tools and returns rewards
Episode Lifecycle
An episode (session) follows this lifecycle:Example Flow
Endpoint Categories
ORS endpoints fall into four categories:1. Discovery Endpoints
Get information about the environment:2. Session Management
Create and manage episodes:3. Episode Interaction
Interact with the active episode:4. Health
Session Management
X-Session-ID Header
Episodes are identified by a session ID passed in theX-Session-ID header:
- Call
POST /create_sessionto get a session ID - Use that ID in all subsequent requests
- Server maintains episode state for that ID
- Call
POST /deleteto clean up
Session Timeout
Sessions automatically expire after 15 minutes of inactivity. To prevent timeout:/ping periodically to keep the session alive. The reference SDK pings every 10 seconds; at minimum, ping well before the 15-minute timeout.
Tool Execution with SSE
Tool calls return results via Server-Sent Events:chunk events before the final end event. See Server-Sent Events for the full event type reference.
Why SSE?
Server-Sent Events are used because:- Long-running tool calls: Keeps connections alive while tools execute (bash commands, LLM calls, etc.)
- Chunking large responses: Results over 4KB are split into chunks for reliable delivery
- Reconnection: Clients can reconnect with a task ID and retrieve completed results
- Standard protocol: Built into browsers and HTTP libraries
Error Handling
HTTP Status Codes
Standard HTTP status codes:- 200 OK: Successful request
- 400 Bad Request: Invalid input
- 404 Not Found: Session/environment/tool not found
- 500 Internal Server Error: Server error
SSE Errors
Errors can also arrive as SSE events during tool execution streaming:{"ok": false, "error": "..."} in an end event. See Server-Sent Events for details.
Tool Errors
Tool execution errors are returned in the ToolOutput:Stateful Sessions
Sessions maintain state across tool calls:- Environment-specific state (variables, files, etc.)
- Task context
- Episode progress
- Client calls
POST /delete(explicit cleanup — calls environment’steardown()) - Session times out after 15 minutes of inactivity (automatic reaper)
The
finished: true signal indicates the episode is logically complete from an RL perspective (e.g., the agent submitted a correct answer). It does not trigger automatic server-side teardown. The client should call POST /delete to free resources after receiving finished: true.- State across different sessions
Security Considerations
Secrets
Tasks can receive secrets via thesecrets field:
Isolation
ORS sessions are isolated at the protocol level. Each session ID maps to its own environment instance with independent state. But deeper isolation depends on the server implementation:- Protocol-level: Each session has its own environment instance and state
- Implementation-level: Filesystem, network, and process isolation require additional infrastructure (e.g., containers, sandboxes)
Implementation Approaches
Option 1: Use ORS Python SDK
The Python SDK implements the full ORS protocol:- HTTP endpoint routing
- Session management
- SSE response delivery
- Error handling
Option 2: Implement from Scratch
Implement the protocol in any language:- Create HTTP server
- Implement required endpoints
- Manage session state
- Return tool outputs via SSE
Next Steps
HTTP API Reference
Complete endpoint documentation
Data Types
Request and response schemas
Session Management
Deep dive on episodes and sessions
Key Takeaway: ORS is a straightforward HTTP protocol with RESTful endpoints for discovery and management, plus SSE for delivering tool execution results. It’s designed to be simple to implement in any language.

