Skip to content
Closed
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
17 changes: 16 additions & 1 deletion rogue/server/api/agentcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

@router.get("/ping")
def ping():
"""
Return the service health status used for liveness checks.

Returns:
dict: JSON object with key "status" whose value is "Healthy".
"""
return {"status": "Healthy"}


Expand All @@ -18,9 +24,18 @@ async def invocations(
evaluation_service: EvaluationService = Depends(get_evaluation_service),
):
# different entrypoint to /evaluations to meet agentcore convention
"""
Enqueue an evaluation request using the agentcore `/invocations` convention.

Parameters:
request (EvaluationRequest): The evaluation request payload to be processed.

Returns:
EvaluationResponse: The enqueued evaluation's status and result data.
"""
return await enqueue_evaluation(
request=request,
background_tasks=background_tasks,
evaluation_service=evaluation_service,
endpoint="/invocations",
)
)
39 changes: 38 additions & 1 deletion rogue/server/api/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@

@lru_cache(1)
def get_evaluation_service():
"""
Provide a single shared EvaluationService instance for request handlers.

Subsequent calls return the same service instance to ensure a single, shared EvaluationService is used across the application.

Returns:
EvaluationService: The shared EvaluationService instance.
"""
return EvaluationService()


Expand All @@ -30,6 +38,18 @@ async def enqueue_evaluation(
evaluation_service: EvaluationService,
endpoint: str,
):
"""
Enqueue a new evaluation job and schedule its execution as a background task.

Parameters:
request (EvaluationRequest): The evaluation request payload containing agent configuration, scenarios, and execution parameters.
background_tasks (BackgroundTasks): FastAPI background task registry used to schedule job execution.
evaluation_service (EvaluationService): Service responsible for persisting and running evaluation jobs.
endpoint (str): The API endpoint path used for context and logging.

Returns:
EvaluationResponse: Contains the created `job_id`, `status` set to `EvaluationStatus.PENDING`, and a success message.
"""
job_id = str(uuid.uuid4())

# Set logging context
Expand Down Expand Up @@ -88,6 +108,12 @@ async def create_evaluation(
background_tasks: BackgroundTasks,
evaluation_service: EvaluationService = Depends(get_evaluation_service),
):
"""
Enqueue an evaluation job for processing and return the created job response.

Returns:
EvaluationResponse: Contains the enqueued job's `job_id`, `status`, and a confirmation message.
"""
return await enqueue_evaluation(
request=request,
background_tasks=background_tasks,
Expand All @@ -103,6 +129,17 @@ async def list_evaluations(
offset: int = 0,
evaluation_service: EvaluationService = Depends(get_evaluation_service),
):
"""
Retrieve a paginated list of evaluation jobs, optionally filtered by status.

Parameters:
status (Optional[EvaluationStatus]): If provided, only include jobs with this status.
limit (int): Maximum number of jobs to return.
offset (int): Number of jobs to skip before collecting the result set.

Returns:
JobListResponse: Contains `jobs` (the returned page of EvaluationJob items) and `total` (the total count of jobs matching the filter).
"""
jobs = await evaluation_service.get_jobs(
status=status,
limit=limit,
Expand Down Expand Up @@ -133,4 +170,4 @@ async def cancel_evaluation(
success = await evaluation_service.cancel_job(job_id)
if not success:
raise HTTPException(status_code=404, detail="Evaluation job not found")
return {"message": "Evaluation job cancelled successfully"}
return {"message": "Evaluation job cancelled successfully"}
12 changes: 11 additions & 1 deletion rogue/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ async def lifespan(app: FastAPI):


def create_app() -> FastAPI:
"""
Create and configure the FastAPI application for the Rogue Agent Evaluator.

The returned app is configured with CORS middleware (allowing all origins and credentials,
and standard methods/headers) and registers the health, evaluation, red-team, LLM,
interview, and websocket routers under the /api/v1 prefix, plus the agent core router at the root.

Returns:
FastAPI: A configured FastAPI application instance.
"""
app = FastAPI(
title="Rogue Agent Evaluator API",
description="API server for the Rogue Agent Evaluator system",
Expand Down Expand Up @@ -115,4 +125,4 @@ def start_server(
host = os.getenv("HOST", "127.0.0.1")
port = int(os.getenv("PORT", "8000"))
reload = os.getenv("RELOAD", "false").lower() in ("true", "1", "yes")
start_server(host, port, reload)
start_server(host, port, reload)
Loading