Skip to content

Conversation

malhotra5
Copy link
Contributor

@malhotra5 malhotra5 commented Sep 26, 2025

Summary

This PR adds support for specifying conversation IDs via command line argument in the OpenHands CLI, allowing users to resume or specify specific conversations.

Changes

Core Functionality

  • Added --id argument: Users can now run openhands-cli --id {conversation_id} to specify a conversation ID
  • Random ID generation: When no ID is provided, a random UUID is generated as before (maintains backward compatibility)
  • UUID validation: Invalid UUIDs are handled gracefully with a warning and fallback to random generation

Implementation Details

  • Modified simple_main.py: Switched from typer to argparse for cleaner argument handling (no additional dependencies)
  • Updated setup_conversation(): Now accepts optional conversation_id parameter with proper validation
  • Updated run_cli_entry(): Passes conversation_id through the entire call chain
  • Maintained backward compatibility: Existing usage without arguments continues to work exactly as before

Usage Examples

# Use random conversation ID (existing behavior)
openhands-cli

# Specify a conversation ID
openhands-cli --id 12345678-1234-5678-9abc-123456789abc

# Get help
openhands-cli --help

Testing

  • ✅ CLI starts successfully with random conversation ID when no argument provided
  • ✅ Help text displays correctly showing the --id option
  • ✅ All pre-commit hooks pass
  • ⚠️ Note: Full conversation resumption testing may be limited due to upstream package dependencies

Technical Notes

  • Switched from typer to argparse (standard library) for simpler dependency management
  • UUID validation ensures only valid conversation IDs are accepted
  • Error handling provides clear feedback for invalid UUIDs
  • Implementation follows existing code patterns and conventions

Backward Compatibility

This change is fully backward compatible. Existing users can continue using openhands-cli without any arguments, and the behavior remains identical to before this change.

@malhotra5 can click here to continue refining the PR


To run this PR locally, use the following command:

GUI with Docker:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:7e498eb-nikolaik   --name openhands-app-7e498eb   docker.all-hands.dev/all-hands-ai/openhands:7e498eb

CLI with uvx:

uvx --python 3.12 --from git+https://github.com/All-Hands-AI/OpenHands@feature/cli-conversation-id openhands

- Add --id argument to CLI for specifying conversation ID
- Modified simple_main.py to use argparse instead of typer for cleaner argument handling
- Updated setup_conversation() to accept optional conversation_id parameter with UUID validation
- Updated run_cli_entry() to pass conversation_id through the call chain
- Fallback to random UUID generation when no ID provided or invalid UUID given
- Maintains backward compatibility with existing usage

Co-authored-by: openhands <[email protected]>
@malhotra5 malhotra5 changed the title feat: Add conversation ID support to OpenHands CLI CLI(V1): resume conversations Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants