Skip to content

πŸ™Œ OpenHands: AI-Driven Development

chore: delete unused Python code identified by vulture analysis (#14111)

Tim O'Farrellb62bdfd143f8
diff --git a/openhands/core/config/arg_utils.py b/openhands/core/config/arg_utils.py
index e0fec320da..5d2cc59ad0 100644
--- a/openhands/core/config/arg_utils.py
+++ b/openhands/core/config/arg_utils.py
@@ -8,15 +8,6 @@
"""Centralized command line argument configuration for OpenHands CLI and headless modes."""
import argparse
-from argparse import ArgumentParser, _SubParsersAction
-
-
-def get_subparser(parser: ArgumentParser, name: str) -> ArgumentParser:
- for action in parser._actions:
- if isinstance(action, _SubParsersAction):
- if name in action.choices:
- return action.choices[name]
- raise ValueError(f"Subparser '{name}' not found")
def add_common_arguments(parser: argparse.ArgumentParser) -> None:
@@ -149,71 +140,6 @@ def add_headless_specific_arguments(parser: argparse.ArgumentParser) -> None:
)
-def get_cli_parser() -> argparse.ArgumentParser:
- """Create argument parser for CLI mode with simplified argument set."""
- # Create a description with welcome message explaining available commands
- description = (
- 'Welcome to OpenHands: Code Less, Make More\n\n'
- 'OpenHands supports two main commands:\n'
- ' serve - Launch the OpenHands GUI server (web interface)\n'
- ' cli - Run OpenHands in CLI mode (terminal interface)\n\n'
- 'Running "openhands" without a command is the same as "openhands cli"'
- )
-
- parser = argparse.ArgumentParser(
- description=description,
- prog='openhands',
- formatter_class=argparse.RawDescriptionHelpFormatter, # Preserve formatting in description
- epilog='For more information about a command, run: openhands COMMAND --help',
- )
-
- # Create subparsers
- subparsers = parser.add_subparsers(
- dest='command',
- title='commands',
- description='OpenHands supports two main commands:',
- metavar='COMMAND',
- )
-
- # Add 'serve' subcommand
- serve_parser = subparsers.add_parser(
- 'serve', help='Launch the OpenHands GUI server using Docker (web interface)'
- )
- serve_parser.add_argument(
- '--mount-cwd',
- help='Mount the current working directory into the GUI server container',
- action='store_true',
- default=False,
- )
- serve_parser.add_argument(
- '--gpu',
- help='Enable GPU support by mounting all GPUs into the Docker container via nvidia-docker',
- action='store_true',
- default=False,
- )
-
- # Add 'cli' subcommand - import all the existing CLI arguments
- cli_parser = subparsers.add_parser(
- 'cli', help='Run OpenHands in CLI mode (terminal interface)'
- )
- add_common_arguments(cli_parser)
-
- cli_parser.add_argument(
- '--override-cli-mode',
- help='Override the default settings for CLI mode',
- type=bool,
- default=False,
- )
- parser.add_argument(
- '--conversation',
- help='The conversation id to continue',
- type=str,
- default=None,
- )
-
- return parser
-
-
def get_headless_parser() -> argparse.ArgumentParser:
"""Create argument parser for headless mode with full argument set."""
parser = argparse.ArgumentParser(description='Run the agent via CLI')
diff --git a/openhands/core/config/utils.py b/openhands/core/config/utils.py
index 38330aff99..3072b1ac6c 100644
--- a/openhands/core/config/utils.py
+++ b/openhands/core/config/utils.py
@@ -23,9 +23,7 @@ from openhands.core import logger
from openhands.core.config.agent_config import AgentConfig
from openhands.core.config.arg_utils import get_headless_parser
from openhands.core.config.condenser_config import (
- CondenserConfig,
condenser_config_from_toml_section,
- create_condenser_config,
)
from openhands.core.config.extended_config import ExtendedConfig
from openhands.core.config.kubernetes_config import KubernetesConfig
@@ -628,118 +626,6 @@ def get_llms_for_routing_config(toml_file: str = 'config.toml') -> dict[str, LLM
return llms_for_routing
-def get_condenser_config_arg(
- condenser_config_arg: str, toml_file: str = 'config.toml'
-) -> CondenserConfig | None:
- """Get a group of condenser settings from the config file by name.
-
- A group in config.toml can look like this:
-
- ```
- [condenser.my_summarizer]
- type = 'llm'
- llm_config = 'gpt-4o' # References [llm.gpt-4o]
- max_size = 50
- ...
- ```
-
- The user-defined group name, like "my_summarizer", is the argument to this function.
- The function will load the CondenserConfig object with the settings of this group,
- from the config file.
-
- Note that the group must be under the "condenser" group, or in other words,
- the group name must start with "condenser.".
-
- Args:
- condenser_config_arg: The group of condenser settings to get from the config.toml file.
- toml_file: Path to the configuration file to read from. Defaults to 'config.toml'.
-
- Returns:
- CondenserConfig: The CondenserConfig object with the settings from the config file, or None if not found/error.
- """
- # keep only the name, just in case
- condenser_config_arg = condenser_config_arg.strip('[]')
-
- # truncate the prefix, just in case
- if condenser_config_arg.startswith('condenser.'):
- condenser_config_arg = condenser_config_arg[10:]
-
- logger.openhands_logger.debug(
- f'Loading condenser config [{condenser_config_arg}] from {toml_file}'
- )
-
- # load the toml file
- try:
- with open(toml_file, 'r', encoding='utf-8') as toml_contents:
- toml_config = toml.load(toml_contents)
- except FileNotFoundError as e:
- logger.openhands_logger.info(f'Config file not found: {toml_file}. Error: {e}')
- return None
- except toml.TomlDecodeError as e:
- logger.openhands_logger.error(
- f'Cannot parse condenser group [{condenser_config_arg}] from {toml_file}. Exception: {e}'
- )
- return None
-
- # Check if the condenser section and the specific config exist
- if (
- 'condenser' not in toml_config
- or condenser_config_arg not in toml_config['condenser']
- ):
- logger.openhands_logger.error(
- f'Condenser config section [condenser.{condenser_config_arg}] not found in {toml_file}'
- )
- return None
-
- condenser_data = toml_config['condenser'][
- condenser_config_arg
- ].copy() # Use copy to modify
-
- # Determine the type and handle potential LLM dependency
- condenser_type = condenser_data.get('type')
- if not condenser_type:
- logger.openhands_logger.error(
- f'Missing "type" field in [condenser.{condenser_config_arg}] section of {toml_file}'
- )
- return None
-
- # Handle LLM config reference if needed, using get_llm_config_arg
- if (
- condenser_type in ('llm', 'llm_attention', 'structured')
- and 'llm_config' in condenser_data
- and isinstance(condenser_data['llm_config'], str)
- ):
- llm_config_name = condenser_data['llm_config']
- logger.openhands_logger.debug(
- f'Condenser [{condenser_config_arg}] requires LLM config [{llm_config_name}]. Loading it...'
- )
- # Use the existing function to load the specific LLM config
- referenced_llm_config = get_llm_config_arg(llm_config_name, toml_file=toml_file)
-
- if referenced_llm_config:
- # Replace the string reference with the actual LLMConfig object
- condenser_data['llm_config'] = referenced_llm_config
- else:
- # get_llm_config_arg already logs the error if not found
- logger.openhands_logger.error(
- f"Failed to load required LLM config '{llm_config_name}' for condenser '{condenser_config_arg}'."
- )
- return None
-
- # Create the condenser config instance
- try:
- config = create_condenser_config(condenser_type, condenser_data)
- logger.openhands_logger.info(
- f'Successfully loaded condenser config [{condenser_config_arg}] from {toml_file}'
- )
- return config
- except (ValidationError, ValueError) as e:
- logger.openhands_logger.error(
- f'Invalid condenser configuration for [{condenser_config_arg}]: {e}.'
- )
- return None
-
-
def get_model_routing_config_arg(toml_file: str = 'config.toml') -> ModelRoutingConfig:
"""Get the model routing settings from the config file. We only support the default model routing config [model_routing].
diff --git a/openhands/core/exceptions.py b/openhands/core/exceptions.py
index 60da78af1f..a58f2669f6 100644
--- a/openhands/core/exceptions.py
+++ b/openhands/core/exceptions.py
@@ -16,16 +16,6 @@ class AgentError(Exception):
pass
-class AgentNoInstructionError(AgentError):
- def __init__(self, message: str = 'Instruction must be provided') -> None:
- super().__init__(message)
-
-
-class AgentEventTypeError(AgentError):
- def __init__(self, message: str = 'Event must be a dictionary') -> None:
- super().__init__(message)
-
-
class AgentAlreadyRegisteredError(AgentError):
def __init__(self, name: str | None = None) -> None:
if name is not None:
@@ -49,20 +39,6 @@ class AgentStuckInLoopError(AgentError):
super().__init__(message)
-# ============================================
-# Agent Controller Exceptions
-# ============================================
-
-
-class TaskInvalidStateError(Exception):
- def __init__(self, state: str | None = None) -> None:
- if state is not None:
- message = f'Invalid state {state}'
- else:
- message = 'Invalid state'
- super().__init__(message)
-
-
# ============================================
# LLM Exceptions
# ============================================
diff --git a/openhands/events/async_event_store_wrapper.py b/openhands/events/async_event_store_wrapper.py
deleted file mode 100644
index c63843fd93..0000000000
--- a/openhands/events/async_event_store_wrapper.py
+++ /dev/null
@@ -1,23 +0,0 @@
-import asyncio
-from typing import Any, AsyncIterator
-
-from openhands.events.event import Event
-from openhands.events.event_store import EventStore
-
-
-class AsyncEventStoreWrapper:
- def __init__(self, event_store: EventStore, *args: Any, **kwargs: Any) -> None:
- self.event_store = event_store
- self.args = args
- self.kwargs = kwargs
-
- async def __aiter__(self) -> AsyncIterator[Event]:
- loop = asyncio.get_running_loop()
-
- # Create an async generator that yields events
- for event in self.event_store.search_events(*self.args, **self.kwargs):
- # Run the blocking search_events() in a thread pool
- def get_event(e: Event = event) -> Event:
- return e
-
- yield await loop.run_in_executor(None, get_event)
diff --git a/openhands/events/utils.py b/openhands/events/utils.py
deleted file mode 100644
index 6d83563dc6..0000000000
--- a/openhands/events/utils.py
+++ /dev/null
@@ -1,61 +0,0 @@
-from openhands.core.logger import openhands_logger as logger
-from openhands.events.action.action import Action
-from openhands.events.action.empty import NullAction
-from openhands.events.event import Event
-from openhands.events.observation import (
- CmdOutputObservation,
- NullObservation,
- Observation,
-)
-
-
-def get_pairs_from_events(events: list[Event]) -> list[tuple[Action, Observation]]:
- """Return the history as a list of tuples (action, observation).
-
- This function is a compatibility function for evals reading and visualization working with old histories.
- """
- tuples: list[tuple[Action, Observation]] = []
- action_map: dict[int, Action] = {}
- observation_map: dict[int, Observation] = {}
-
- # runnable actions are set as cause of observations
- # (MessageAction, NullObservation) for source=USER
- # (MessageAction, NullObservation) for source=AGENT
- # (other_action?, NullObservation)
- # (NullAction, CmdOutputObservation) background CmdOutputObservations
-
- for event in events:
- if event.id is None or event.id == -1:
- logger.debug(f'Event {event} has no ID')
-
- if isinstance(event, Action):
- action_map[event.id] = event
-
- if isinstance(event, Observation):
- if event.cause is None or event.cause == -1:
- logger.debug(f'Observation {event} has no cause')
-
- if event.cause is None:
- # runnable actions are set as cause of observations
- # NullObservations have no cause
- continue
-
- observation_map[event.cause] = event
-
- for action_id, action in action_map.items():
- observation = observation_map.get(action_id)
- if observation:
- # observation with a cause
- tuples.append((action, observation))
- else:
- tuples.append((action, NullObservation('')))
-
- for cause_id, observation in observation_map.items():
- if cause_id not in action_map:
- if isinstance(observation, NullObservation):
- continue
- if not isinstance(observation, CmdOutputObservation):
- logger.debug(f'Observation {observation} has no cause')
- tuples.append((NullAction(), observation))
-
- return tuples.copy()
diff --git a/openhands/integrations/service_types.py b/openhands/integrations/service_types.py
index e96d61a184..110f0c687b 100644
--- a/openhands/integrations/service_types.py
+++ b/openhands/integrations/service_types.py
@@ -120,12 +120,6 @@ class SuggestedTask(BaseModel):
return template.render(issue_number=issue_number, repo=repo, **terms)
-class CreateMicroagent(BaseModel):
- repo: str
- git_provider: ProviderType | None = None
- title: str | None = None
-
-
class UserGitInfo(BaseModel):
id: str
login: str
diff --git a/openhands/runtime/plugins/agent_skills/file_ops/file_ops.py b/openhands/runtime/plugins/agent_skills/file_ops/file_ops.py
index d24063bf12..8a75862176 100644
--- a/openhands/runtime/plugins/agent_skills/file_ops/file_ops.py
+++ b/openhands/runtime/plugins/agent_skills/file_ops/file_ops.py
@@ -43,40 +43,6 @@ def _output_error(error_msg: str) -> bool:
return False
-def _is_valid_filename(file_name: str) -> bool:
- if not file_name or not isinstance(file_name, str) or not file_name.strip():
- return False
- invalid_chars = '<>:"/\\|?*'
- if os.name == 'nt': # Windows
- invalid_chars = '<>:"/\\|?*'
- elif os.name == 'posix': # Unix-like systems
- invalid_chars = '\0'
-
- for char in invalid_chars:
- if char in file_name:
- return False
- return True
-
-
-def _is_valid_path(path: str) -> bool:
- if not path or not isinstance(path, str):
- return False
- try:
- return os.path.exists(os.path.normpath(path))
- except PermissionError:
- return False
-
-
-def _create_paths(file_name: str) -> bool:
- try:
- dirname = os.path.dirname(file_name)
- if dirname:
- os.makedirs(dirname, exist_ok=True)
- return True
- except PermissionError:
- return False
-
-
def _check_current_file(file_path: str | None = None) -> bool:
global CURRENT_FILE
if not file_path:
@@ -269,10 +235,6 @@ def scroll_up() -> None:
print(output)
-class LineNumberError(Exception):
- pass
-
-
def search_dir(search_term: str, dir_path: str = './') -> None:
"""Searches for search_term in all files in dir. If dir is not provided, searches in the current directory.
diff --git a/openhands/runtime/utils/log_capture.py b/openhands/runtime/utils/log_capture.py
deleted file mode 100644
index 9f4edf28bf..0000000000
--- a/openhands/runtime/utils/log_capture.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# IMPORTANT: LEGACY V0 CODE - Deprecated since version 1.0.0, scheduled for removal April 1, 2026
-# This file is part of the legacy (V0) implementation of OpenHands and will be removed soon as we complete the migration to V1.
-# OpenHands V1 uses the Software Agent SDK for the agentic core and runs a new application server. Please refer to:
-# - V1 agentic core (SDK): https://github.com/OpenHands/software-agent-sdk
-# - V1 application server (in this repo): openhands/app_server/
-# Unless you are working on deprecation, please avoid extending this legacy file and consult the V1 codepaths above.
-# Tag: Legacy-V0
-import io
-import logging
-from contextlib import asynccontextmanager
-
-
-@asynccontextmanager
-async def capture_logs(logger_name, level=logging.ERROR):
- logger = logging.getLogger(logger_name)
-
- # Store original handlers and level
- original_handlers = logger.handlers[:]
- original_level = logger.level
-
- # Set up capture
- log_capture = io.StringIO()
- handler = logging.StreamHandler(log_capture)
- handler.setLevel(level)
-
- logger.handlers = [handler]
- logger.setLevel(level)
-
- try:
- yield log_capture
- finally:
- # Restore original configuration
- logger.handlers = original_handlers
- logger.setLevel(original_level)
diff --git a/openhands/runtime/utils/port_lock.py b/openhands/runtime/utils/port_lock.py
index 0e655fa79a..e5dfe42f1a 100644
--- a/openhands/runtime/utils/port_lock.py
+++ b/openhands/runtime/utils/port_lock.py
@@ -232,44 +232,3 @@ def _check_port_available(port: int, bind_address: str = '0.0.0.0') -> bool:
return True
except OSError:
return False
-
-
-def cleanup_stale_locks(max_age_seconds: int = 300) -> int:
- """Clean up stale lock files.
-
- Args:
- max_age_seconds: Maximum age of lock files before they're considered stale
-
- Returns:
- Number of lock files cleaned up
- """
- lock_dir = os.path.join(tempfile.gettempdir(), 'openhands_port_locks')
- if not os.path.exists(lock_dir):
- return 0
-
- cleaned = 0
- current_time = time.time()
-
- try:
- for filename in os.listdir(lock_dir):
- if filename.startswith('port_') and filename.endswith('.lock'):
- lock_path = os.path.join(lock_dir, filename)
- try:
- # Check if lock file is old
- stat = os.stat(lock_path)
- if current_time - stat.st_mtime > max_age_seconds:
- # Try to remove stale lock
- os.unlink(lock_path)
- cleaned += 1
- logger.debug(f'Cleaned up stale lock file: {filename}')
- except (OSError, FileNotFoundError):
- # File might have been removed by another process
- pass
- except OSError:
- # Directory might not exist or be accessible
- pass
-
- if cleaned > 0:
- logger.info(f'Cleaned up {cleaned} stale port lock files')
-
- return cleaned
diff --git a/openhands/server/data_models/agent_loop_info.py b/openhands/server/data_models/agent_loop_info.py
deleted file mode 100644
index 406acddb8b..0000000000
--- a/openhands/server/data_models/agent_loop_info.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# IMPORTANT: LEGACY V0 CODE - Deprecated since version 1.0.0, scheduled for removal April 1, 2026
-# This file is part of the legacy (V0) implementation of OpenHands and will be removed soon as we complete the migration to V1.
-# OpenHands V1 uses the Software Agent SDK for the agentic core and runs a new application server. Please refer to:
-# - V1 agentic core (SDK): https://github.com/OpenHands/software-agent-sdk
-# - V1 application server (in this repo): openhands/app_server/
-# Unless you are working on deprecation, please avoid extending this legacy file and consult the V1 codepaths above.
-# Tag: Legacy-V0
-# This module belongs to the old V0 web server. The V1 application server lives under openhands/app_server/.
-from dataclasses import dataclass, field
-
-from openhands.events.event_store_abc import EventStoreABC
-from openhands.runtime.runtime_status import RuntimeStatus
-from openhands.storage.data_models.conversation_status import ConversationStatus
-
-
-@dataclass
-class AgentLoopInfo:
- """Information about an agent loop - the URL on which to locate it and the event store"""
-
- conversation_id: str
- url: str | None
- session_api_key: str | None
- event_store: EventStoreABC | None
- status: ConversationStatus = field(default=ConversationStatus.RUNNING)
- runtime_status: RuntimeStatus | None = None
diff --git a/openhands/server/data_models/conversation_info_result_set.py b/openhands/server/data_models/conversation_info_result_set.py
deleted file mode 100644
index e9820b8484..0000000000
--- a/openhands/server/data_models/conversation_info_result_set.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# IMPORTANT: LEGACY V0 CODE - Deprecated since version 1.0.0, scheduled for removal April 1, 2026
-# This file is part of the legacy (V0) implementation of OpenHands and will be removed soon as we complete the migration to V1.
-# OpenHands V1 uses the Software Agent SDK for the agentic core and runs a new application server. Please refer to:
-# - V1 agentic core (SDK): https://github.com/OpenHands/software-agent-sdk
-# - V1 application server (in this repo): openhands/app_server/
-# Unless you are working on deprecation, please avoid extending this legacy file and consult the V1 codepaths above.
-# Tag: Legacy-V0
-# This module belongs to the old V0 web server. The V1 application server lives under openhands/app_server/.
-from dataclasses import dataclass, field
-
-from openhands.server.data_models.conversation_info import ConversationInfo
-
-
-@dataclass
-class ConversationInfoResultSet:
- results: list[ConversationInfo] = field(default_factory=list)
- next_page_id: str | None = None
diff --git a/openhands/server/data_models/feedback.py b/openhands/server/data_models/feedback.py
deleted file mode 100644
index a57b8abf9f..0000000000
--- a/openhands/server/data_models/feedback.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# IMPORTANT: LEGACY V0 CODE - Deprecated since version 1.0.0, scheduled for removal April 1, 2026
-# This file is part of the legacy (V0) implementation of OpenHands and will be removed soon as we complete the migration to V1.
-# OpenHands V1 uses the Software Agent SDK for the agentic core and runs a new application server. Please refer to:
-# - V1 agentic core (SDK): https://github.com/OpenHands/software-agent-sdk
-# - V1 application server (in this repo): openhands/app_server/
-# Unless you are working on deprecation, please avoid extending this legacy file and consult the V1 codepaths above.
-# Tag: Legacy-V0
-# This module belongs to the old V0 web server. The V1 application server lives under openhands/app_server/.
-import json
-from typing import Any, Literal
-
-import httpx
-from pydantic import BaseModel
-
-from openhands.core.logger import openhands_logger as logger
-
-
-class FeedbackDataModel(BaseModel):
- version: str
- email: str
- polarity: Literal['positive', 'negative']
- feedback: Literal[
- 'positive', 'negative'
- ] # TODO: remove this, its here for backward compatibility
- permissions: Literal['public', 'private']
- trajectory: list[dict[str, Any]] | None
-
-
-FEEDBACK_URL = 'https://share-od-trajectory-3u9bw9tx.uc.gateway.dev/share_od_trajectory'
-
-
-def store_feedback(feedback: FeedbackDataModel) -> dict[str, str]:
- # Start logging
- feedback.feedback = feedback.polarity
- display_feedback = feedback.model_dump()
- if 'trajectory' in display_feedback:
- display_feedback['trajectory'] = (
- f'elided [length: {len(display_feedback["trajectory"])}'
- )
- if 'token' in display_feedback:
- display_feedback['token'] = 'elided'
- logger.debug(f'Got feedback: {display_feedback}')
- # Start actual request
- response = httpx.post(
- FEEDBACK_URL,
- headers={'Content-Type': 'application/json'},
- json=feedback.model_dump(),
- )
- if response.status_code != 200:
- raise ValueError(f'Failed to store feedback: {response.text}')
- response_data: dict[str, str] = json.loads(response.text)
- logger.debug(f'Stored feedback: {response.text}')
- return response_data
diff --git a/openhands/server/files.py b/openhands/server/files.py
deleted file mode 100644
index 2640a00bb9..0000000000
--- a/openhands/server/files.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# IMPORTANT: LEGACY V0 CODE - Deprecated since version 1.0.0, scheduled for removal April 1, 2026
-# This file is part of the legacy (V0) implementation of OpenHands and will be removed soon as we complete the migration to V1.
-# OpenHands V1 uses the Software Agent SDK for the agentic core and runs a new application server. Please refer to:
-# - V1 agentic core (SDK): https://github.com/OpenHands/software-agent-sdk
-# - V1 application server (in this repo): openhands/app_server/
-# Unless you are working on deprecation, please avoid extending this legacy file and consult the V1 codepaths above.
-# Tag: Legacy-V0
-# This module belongs to the old V0 web server. The V1 application server lives under openhands/app_server/.
-from pydantic import (
- BaseModel,
-)
-
-
-class POSTUploadFilesModel(BaseModel):
- """Upload files response model"""
-
- file_urls: list[str]
- skipped_files: list[str]
diff --git a/openhands/server/settings.py b/openhands/server/settings.py
index bc799af438..f5eb73aaca 100644
--- a/openhands/server/settings.py
+++ b/openhands/server/settings.py
@@ -11,11 +11,10 @@ from __future__ import annotations
from pydantic import (
BaseModel,
ConfigDict,
- SecretStr,
)
from openhands.core.config.mcp_config import MCPConfig
-from openhands.integrations.provider import CustomSecret, ProviderToken
+from openhands.integrations.provider import ProviderToken
from openhands.integrations.service_types import ProviderType
from openhands.storage.data_models.settings import Settings
@@ -27,12 +26,6 @@ class POSTProviderModel(BaseModel):
provider_tokens: dict[ProviderType, ProviderToken] = {}
-class POSTCustomSecrets(BaseModel):
- """Adding new custom secret"""
-
- custom_secrets: dict[str, CustomSecret] = {}
-
-
class GETSettingsModel(Settings):
"""Settings with additional token data for the frontend"""
@@ -50,15 +43,3 @@ class CustomSecretWithoutValueModel(BaseModel):
name: str
description: str | None = None
-
-
-class CustomSecretModel(CustomSecretWithoutValueModel):
- """Custom secret model with value"""
-
- value: SecretStr
-
-
-class GETCustomSecrets(BaseModel):
- """Custom secrets names"""
-
- custom_secrets: list[CustomSecretWithoutValueModel] | None = None
diff --git a/openhands/server/utils.py b/openhands/server/utils.py
index a97b1bf809..0a8a045454 100644
--- a/openhands/server/utils.py
+++ b/openhands/server/utils.py
@@ -6,8 +6,6 @@
# Unless you are working on deprecation, please avoid extending this legacy file and consult the V1 codepaths above.
# Tag: Legacy-V0
# This module belongs to the old V0 web server. The V1 application server lives under openhands/app_server/.
-import uuid
-
from fastapi import Depends, HTTPException, Request, status
from openhands.server.shared import (
@@ -75,15 +73,6 @@ async def get_conversation_store(request: Request) -> ConversationStore | None:
return conversation_store
-async def generate_unique_conversation_id(
- conversation_store: ConversationStore,
-) -> str:
- conversation_id = uuid.uuid4().hex
- while await conversation_store.exists(conversation_id):
- conversation_id = uuid.uuid4().hex
- return conversation_id
-
-
async def get_conversation_metadata(
conversation_id: str,
conversation_store: ConversationStore = Depends(get_conversation_store),
diff --git a/openhands/storage/locations.py b/openhands/storage/locations.py
index 0b1ec72c1d..7d68deeef7 100644
--- a/openhands/storage/locations.py
+++ b/openhands/storage/locations.py
@@ -22,17 +22,9 @@ def get_conversation_metadata_filename(sid: str, user_id: str | None = None) ->
return f'{get_conversation_dir(sid, user_id)}metadata.json'
-def get_conversation_init_data_filename(sid: str, user_id: str | None = None) -> str:
- return f'{get_conversation_dir(sid, user_id)}init.json'
-
-
def get_conversation_agent_state_filename(sid: str, user_id: str | None = None) -> str:
return f'{get_conversation_dir(sid, user_id)}agent_state.pkl'
-def get_conversation_llm_registry_filename(sid: str, user_id: str | None = None) -> str:
- return f'{get_conversation_dir(sid, user_id)}llm_registry.json'
-
-
def get_conversation_stats_filename(sid: str, user_id: str | None = None) -> str:
return f'{get_conversation_dir(sid, user_id)}conversation_stats.pkl'
diff --git a/openhands/utils/shutdown_listener.py b/openhands/utils/shutdown_listener.py
index b444c2c2bc..c8fb8e0ad5 100644
--- a/openhands/utils/shutdown_listener.py
+++ b/openhands/utils/shutdown_listener.py
@@ -2,7 +2,6 @@
does not play nocely with stareltte / uvicorn shutdown signals.
"""
-import asyncio
import signal
import threading
import time
@@ -74,15 +73,6 @@ def sleep_if_should_continue(timeout: float) -> None:
time.sleep(1)
-async def async_sleep_if_should_continue(timeout: float) -> None:
- if timeout <= 1:
- await asyncio.sleep(timeout)
- return
- start_time = time.time()
- while time.time() - start_time < timeout and should_continue():
- await asyncio.sleep(1)
-
-
def add_shutdown_listener(callable: Callable) -> UUID:
id_ = uuid4()
_shutdown_listeners[id_] = callable