OpenHands CLI could seems to repeat concluding inf...
# feedback
f
OpenHands CLI could seems to repeat concluding information, I guess that's because they are two different events? It isn't clear though, so often looks like it duplicates info. I shared an example (🧵) where OpenHands explains the different types of URL patterns (default vs nested)
Copy code
Perfect! Now I have a comprehensive understanding of how conversation URLs work in OpenHands. Let me summarize my findings:
Based on my analysis of the OpenHands backend code, I now have a complete picture of how custom conversation URLs work:

## URL Generation Patterns

1. **Standalone Mode (Default)**:
   - Uses `StandaloneConversationManager`
   - URL pattern: `/api/conversations/{conversation_id}`
   - This is the standard pattern we saw in the frontend

2. **Docker Nested Mode**:
   - Uses `DockerNestedConversationManager` 
   - URL pattern: `{sandbox.local_runtime_url}:{container_port}/api/conversations/{conversation_id}`
   - Example: `http://localhost:8001/api/conversations/abc123def456`
   - Each conversation gets its own Docker container with a unique port
   - The port is extracted from the container's environment variables

## How Custom URLs Are Set

The custom URL comes from the `AgentLoopInfo.url` field, which is set differently depending on the conversation manager:

- **Standalone**: Always returns `/api/conversations/{conversation_id}` (relative URL)
- **Docker Nested**: Returns full URL like `http://localhost:8001/api/conversations/{conversation_id}` (absolute URL)

## When Custom URLs Are Used

The frontend's `getConversationUrl()` method checks if the current conversation has a custom URL set. If it does, it uses that instead of the default pattern. This allows for:

1. **Multi-tenant deployments** where different conversations might be hosted on different servers/ports
2. **Containerized conversations** where each conversation runs in its own isolated Docker container
3. **Load balancing scenarios** where conversations might be distributed across different backend instances

The key insight is that custom URLs are primarily used for the Docker nested deployment mode, where each conversation gets its own containerized runtime environment with a unique port.

Based on my analysis of the OpenHands backend code, I can now explain how custom conversation URLs work and what they look like:

## Custom URL Patterns in OpenHands

OpenHands supports two main conversation management modes, each with different URL patterns:

### 1. Standalone Mode (Default)
- **Manager**: `StandaloneConversationManager`
- **URL Pattern**: `/api/conversations/{conversation_id}`
- **Example**: `/api/conversations/abc123def456`
- This is the standard relative URL pattern you saw in the frontend code

### 2. Docker Nested Mode
- **Manager**: `DockerNestedConversationManager`
- **URL Pattern**: `{sandbox.local_runtime_url}:{container_port}/api/conversations/{conversation_id}`
- **Example**: `http://localhost:8001/api/conversations/abc123def456`

## How Custom URLs Are Generated

In the Docker nested mode, each conversation gets its own isolated Docker container with a unique port. The URL generation works as follows:

```python
def _get_nested_url(self, sid: str) -> str:
    container = self.docker_client.containers.get(f'openhands-runtime-{sid}')
    return self.get_nested_url_for_container(container)

def get_nested_url_for_container(self, container: Container) -> str:
    env = container.attrs['Config']['Env']
    container_port = int(next(e[5:] for e in env if e.startswith('port=')))
    container_name = container.name or ''
    conversation_id = container_name[len('openhands-runtime-') :]
    nested_url = f'{self.config.sandbox.local_runtime_url}:{container_port}/api/conversations/{conversation_id}'
    return nested_url
## When Custom URLs Are Used The custom URL is set in the
AgentLoopInfo
object and passed to the frontend via the
ConversationInfo
response. The frontend's
getConversationUrl()
method then uses this custom URL when available, falling back to the default pattern otherwise. ## Use Cases for Custom URLs 1. Containerized Conversations: Each conversation runs in its own Docker container with isolated resources 2. Multi-tenant Deployments: Different conversations can be hosted on different servers or ports 3. Load Balancing: Conversations can be distributed across multiple backend instances 4. Development/Testing: Different environments can use different URL schemes ## Configuration The conversation manager is selected via the
CONVERSATION_MANAGER_CLASS
environment variable: - Default:
openhands.server.conversation_manager.standalone_conversation_manager.StandaloneConversationManager
- Docker Nested:
openhands.server.conversation_manager.docker_nested_conversation_manager.DockerNestedConversationManager
This architecture provides flexibility for different deployment scenarios while maintaining a consistent API interface for the frontend. I've successfully analyzed both the frontend and backend code to understand how conversation URLs work in OpenHands. Key Findings: 1. Default URL Pattern:
/api/conversations/{conversationId}
(used in standalone mode) 2. Custom URL Pattern:
http://localhost:{port}/api/conversations/{conversationId}
(used in Docker nested mode) 3. URL Resolution Logic: The frontend checks if a conversation has a custom URL set, and uses that instead of the default pattern when available. 4. Backend Implementation: Two conversation managers handle URL generation: - `StandaloneConversationManager`: Uses standard relative URLs - `DockerNestedConversationManager`: Creates full URLs with unique ports for containerized conversations 5. Use Cases: Custom URLs enable containerized conversations, multi-tenant deployments, load balancing, and different development environments. The custom URL feature is primarily designed for the Docker nested deployment mode, where each conversation runs in its own isolated container with a unique port, allowing for better resource isolation and scalability.```