Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions openhands-agent-server/openhands/agent_server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
check_workspace_session,
)
from openhands.agent_server.errors import GatewayTimeout, status_for
from openhands.agent_server.epic_poem_router import epic_poem_router
from openhands.agent_server.experimental_features_router import (
experimental_features_router,
)
Expand Down Expand Up @@ -683,6 +684,7 @@ def _add_api_routes(app: FastAPI) -> None:
api_router.include_router(provider_connections_router)
api_router.include_router(mcp_router)
api_router.include_router(experimental_features_router)
api_router.include_router(epic_poem_router)
api_router.include_router(settings_router)
api_router.include_router(workspaces_router)
api_router.include_router(projects_router)
Expand Down
32 changes: 32 additions & 0 deletions openhands-agent-server/openhands/agent_server/epic_poem_router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Epic poem demo endpoint.

Returns the poem name used by the ``/epic-poem`` slash command. The value
is sourced from the ``EPIC_POEM_NAME`` environment variable (default
``"The OpenHands Epic"``) so a preview deployment can override it.

This is the agent-server leg of the ``/epic-poem`` cross-repo demo used to
exercise the ``verify-this`` preview-verification automation with a
multi-PR, multi-repo bundle.
"""

import os

from fastapi import APIRouter
from pydantic import BaseModel

epic_poem_router = APIRouter(prefix="/epic-poem", tags=["Epic poem"])

DEFAULT_EPIC_POEM_NAME = "The OpenHands Epic"


class EpicPoemName(BaseModel):
name: str


@epic_poem_router.get("/name", response_model=EpicPoemName)
async def get_epic_poem_name() -> EpicPoemName:
"""Return the poem's title."""
name = os.environ.get("EPIC_POEM_NAME", DEFAULT_EPIC_POEM_NAME).strip()
if not name:
name = DEFAULT_EPIC_POEM_NAME
return EpicPoemName(name=name)
35 changes: 35 additions & 0 deletions tests/agent_server/test_epic_poem_router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Tests for the epic poem demo endpoint."""

from fastapi.testclient import TestClient

from openhands.agent_server.api import create_app
from openhands.agent_server.config import Config


def _client() -> TestClient:
config = Config(session_api_keys=[]) # Disable authentication
return TestClient(create_app(config), raise_server_exceptions=False)


def test_get_epic_poem_name_default(monkeypatch):
monkeypatch.delenv("EPIC_POEM_NAME", raising=False)
with _client() as client:
response = client.get("/api/epic-poem/name")
assert response.status_code == 200
assert response.json() == {"name": "The OpenHands Epic"}


def test_get_epic_poem_name_env_override(monkeypatch):
monkeypatch.setenv("EPIC_POEM_NAME", "The Preview Epic")
with _client() as client:
response = client.get("/api/epic-poem/name")
assert response.status_code == 200
assert response.json() == {"name": "The Preview Epic"}


def test_get_epic_poem_name_blank_env_falls_back(monkeypatch):
monkeypatch.setenv("EPIC_POEM_NAME", " ")
with _client() as client:
response = client.get("/api/epic-poem/name")
assert response.status_code == 200
assert response.json() == {"name": "The OpenHands Epic"}
Loading