Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:OpenHands OpenHands Version

From Leeroopedia
Revision as of 11:43, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/OpenHands_OpenHands_Version.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains UI_Components, React
Last Updated 2026-02-11 21:00 GMT

Overview

A Python module providing multi-layered version detection for the OpenHands package with graceful fallback strategies.

Description

The version module exposes the package version through the __version__ variable and the get_version() function. It implements a multi-layered detection strategy that attempts the following sources in order:

  1. pyproject.toml — Reads the version directly from the project's pyproject.toml file if available in the source tree.
  2. importlib.metadata — Uses the standard library importlib.metadata module to query the installed package version.
  3. pkg_resources — Falls back to the legacy pkg_resources API from setuptools for older environments.
  4. "unknown" — Returns the string "unknown" if all detection methods fail.

The module also exports a __package_name__ variable containing the canonical package name. The source file is 44 lines long.

Usage

Use this module to programmatically determine the installed version of OpenHands at runtime. It is commonly used in CLI output, logging, HTTP user-agent headers, telemetry, and diagnostic information.

Code Reference

Source Location

openhands/version.py (44 lines)

Signature

// Note: This module is Python, not TypeScript.
// Python signature:

def get_version() -> str:
    """Returns the package version string, or 'unknown' if detection fails."""
    ...

__version__: str
__package_name__: str

Import

// Python import:
// from openhands.version import __version__
// from openhands.version import get_version

I/O Contract

Inputs (Props)

The get_version() function takes no arguments. It reads from the environment and filesystem automatically.

Outputs

Output Type Description
get_version() return value str The detected version string (e.g., "1.11.4") or "unknown" if all detection methods fail.
__version__ str Module-level variable holding the result of get_version(), evaluated at import time.
__package_name__ str The canonical name of the package (e.g., "openhands").

Usage Examples

// Python usage examples:

// Basic version check
from openhands.version import __version__
print(f"OpenHands version: {__version__}")

// Using the function directly
from openhands.version import get_version
version = get_version()
if version == "unknown":
    print("Warning: Could not determine package version")

// In a CLI tool
from openhands.version import __version__, __package_name__
print(f"{__package_name__} v{__version__}")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment