Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Added flag to disable the V1 endpoints inside nested V0 runtimes (#11391)

Tim O'Farrellf4fd8ea9079a
diff --git a/enterprise/server/saas_nested_conversation_manager.py b/enterprise/server/saas_nested_conversation_manager.py
index 469b71e33d..6eb03a66e3 100644
--- a/enterprise/server/saas_nested_conversation_manager.py
+++ b/enterprise/server/saas_nested_conversation_manager.py
@@ -784,6 +784,7 @@ class SaasNestedConversationManager(ConversationManager):
env_vars['SKIP_DEPENDENCY_CHECK'] = '1'
env_vars['INITIAL_NUM_WARM_SERVERS'] = '1'
env_vars['INIT_GIT_IN_EMPTY_WORKSPACE'] = '1'
+ env_vars['ENABLE_V1'] = '0'
# We need this for LLM traces tracking to identify the source of the LLM calls
env_vars['WEB_HOST'] = WEB_HOST
diff --git a/enterprise/server/utils/conversation_callback_utils.py b/enterprise/server/utils/conversation_callback_utils.py
index dc36b0c703..9224e686bf 100644
--- a/enterprise/server/utils/conversation_callback_utils.py
+++ b/enterprise/server/utils/conversation_callback_utils.py
@@ -195,14 +195,11 @@ def update_active_working_seconds(
file_store: The FileStore instance for accessing conversation data
"""
try:
- # Get all events for the conversation
- events = list(event_store.get_events())
-
# Track agent state changes and calculate running time
running_start_time = None
total_running_seconds = 0.0
- for event in events:
+ for event in event_store.search_events():
if isinstance(event, AgentStateChangedObservation) and event.timestamp:
event_timestamp = datetime.fromisoformat(event.timestamp).timestamp()
diff --git a/enterprise/tests/unit/server/test_conversation_callback_utils.py b/enterprise/tests/unit/server/test_conversation_callback_utils.py
index 598befe79a..128f2d82d2 100644
--- a/enterprise/tests/unit/server/test_conversation_callback_utils.py
+++ b/enterprise/tests/unit/server/test_conversation_callback_utils.py
@@ -80,7 +80,7 @@ class TestUpdateActiveWorkingSeconds:
events.append(event6)
# Configure the mock event store to return our test events
- mock_event_store.get_events.return_value = events
+ mock_event_store.search_events.return_value = events
# Call the function under test with mocked session_maker
with patch(
@@ -133,7 +133,7 @@ class TestUpdateActiveWorkingSeconds:
events = [event1, event2]
- mock_event_store.get_events.return_value = events
+ mock_event_store.search_events.return_value = events
# Call the function under test with mocked session_maker
with patch(
@@ -178,7 +178,7 @@ class TestUpdateActiveWorkingSeconds:
events = [event1, event2, event3]
# No final state change - agent still running
- mock_event_store.get_events.return_value = events
+ mock_event_store.search_events.return_value = events
# Call the function under test with mocked session_maker
with patch(
@@ -221,7 +221,7 @@ class TestUpdateActiveWorkingSeconds:
events = [event1, event2, event3]
- mock_event_store.get_events.return_value = events
+ mock_event_store.search_events.return_value = events
# Call the function under test with mocked session_maker
with patch(
@@ -267,7 +267,7 @@ class TestUpdateActiveWorkingSeconds:
events = [event1, event2, event3, event4]
- mock_event_store.get_events.return_value = events
+ mock_event_store.search_events.return_value = events
# Call the function under test with mocked session_maker
with patch(
@@ -297,7 +297,7 @@ class TestUpdateActiveWorkingSeconds:
user_id = 'test_user_error'
# Configure the mock to raise an exception
- mock_event_store.get_events.side_effect = Exception('Test error')
+ mock_event_store.search_events.side_effect = Exception('Test error')
# Call the function under test
update_active_working_seconds(
@@ -376,7 +376,7 @@ class TestUpdateActiveWorkingSeconds:
event10.timestamp = '1970-01-01T00:00:37.000000'
events.append(event10)
- mock_event_store.get_events.return_value = events
+ mock_event_store.search_events.return_value = events
# Call the function under test with mocked session_maker
with patch(
diff --git a/openhands/core/config/openhands_config.py b/openhands/core/config/openhands_config.py
index 24990bc770..d2905832be 100644
--- a/openhands/core/config/openhands_config.py
+++ b/openhands/core/config/openhands_config.py
@@ -89,8 +89,8 @@ class OpenHandsConfig(BaseModel):
)
# Deprecated parameters - will be removed in a future version
- workspace_mount_path: str | None = Field(default=None, deprecated=True)
- workspace_mount_rewrite: str | None = Field(default=None, deprecated=True)
+ workspace_mount_path: str | None = Field(default=None)
+ workspace_mount_rewrite: str | None = Field(default=None)
# End of deprecated parameters
cache_dir: str = Field(default='/tmp/cache')
diff --git a/openhands/core/config/utils.py b/openhands/core/config/utils.py
index 8daeb2b5ad..2e68878eb9 100644
--- a/openhands/core/config/utils.py
+++ b/openhands/core/config/utils.py
@@ -376,11 +376,6 @@ def get_or_create_jwt_secret(file_store: FileStore) -> str:
def finalize_config(cfg: OpenHandsConfig) -> None:
"""More tweaks to the config after it's been loaded."""
# Handle the sandbox.volumes parameter
- if cfg.workspace_base is not None or cfg.workspace_mount_path is not None:
- logger.openhands_logger.warning(
- 'DEPRECATED: The WORKSPACE_BASE and WORKSPACE_MOUNT_PATH environment variables are deprecated. '
- "Please use SANDBOX_VOLUMES instead, e.g. 'SANDBOX_VOLUMES=/my/host/dir:/workspace:rw'"
- )
if cfg.sandbox.volumes is not None:
# Split by commas to handle multiple mounts
mounts = cfg.sandbox.volumes.split(',')
diff --git a/openhands/server/app.py b/openhands/server/app.py
index f78809992b..d5135f2399 100644
--- a/openhands/server/app.py
+++ b/openhands/server/app.py
@@ -90,6 +90,7 @@ app.include_router(settings_router)
app.include_router(secrets_router)
if server_config.app_mode == AppMode.OSS:
app.include_router(git_api_router)
-app.include_router(v1_router.router)
+if server_config.enable_v1:
+ app.include_router(v1_router.router)
app.include_router(trajectory_router)
add_health_endpoints(app)
diff --git a/openhands/server/config/server_config.py b/openhands/server/config/server_config.py
index e471ff8951..4175227267 100644
--- a/openhands/server/config/server_config.py
+++ b/openhands/server/config/server_config.py
@@ -30,6 +30,7 @@ class ServerConfig(ServerConfigInterface):
user_auth_class: str = (
'openhands.server.user_auth.default_user_auth.DefaultUserAuth'
)
+ enable_v1: bool = os.getenv('ENABLE_V1') != '0'
def verify_config(self):
if self.config_cls:
diff --git a/openhands/storage/data_models/settings.py b/openhands/storage/data_models/settings.py
index aaa50aa9d2..fe37b241c9 100644
--- a/openhands/storage/data_models/settings.py
+++ b/openhands/storage/data_models/settings.py
@@ -10,7 +10,6 @@ from pydantic import (
field_validator,
model_validator,
)
-from pydantic.json import pydantic_encoder
from openhands.core.config.llm_config import LLMConfig
from openhands.core.config.mcp_config import MCPConfig
@@ -72,7 +71,7 @@ class Settings(BaseModel):
if context and context.get('expose_secrets', False):
return secret_value
- return pydantic_encoder(api_key)
+ return str(api_key)
@model_validator(mode='before')
@classmethod