From d9a0d61e29ef8b4627baca5737e339858b92c742 Mon Sep 17 00:00:00 2001 From: asimurka Date: Mon, 23 Nov 2026 10:40:12 +0100 Subject: [PATCH] Exposed v3/conversations endpoint --- docs/devel_doc/openapi.json | 3663 +++++++++++++---- docs/models/error_responses.json | 16 +- src/app/README.md | 8 + src/app/endpoints/README.md | 4 + src/app/endpoints/conversations_v2.py | 1 - src/app/endpoints/conversations_v3.py | 275 ++ src/app/main.py | 1 + src/app/routers.py | 7 +- .../persistence/facade/conversation.py | 13 +- src/models/api/responses/error/internal.py | 7 + .../api/responses/successful/conversations.py | 16 +- tests/integration/test_openapi_json.py | 32 + tests/unit/app/endpoints/README.md | 4 + .../app/endpoints/test_conversations_v2.py | 2 +- .../app/endpoints/test_conversations_v3.py | 266 ++ tests/unit/app/test_routers.py | 12 +- .../persistence/facade/test_conversation.py | 13 +- .../models/responses/test_error_responses.py | 3 +- .../responses/test_successful_responses.py | 9 +- .../unit/utils/dumpers/test_models_dumper.py | 7 + 20 files changed, 3482 insertions(+), 877 deletions(-) create mode 100644 src/app/endpoints/conversations_v3.py create mode 100644 tests/unit/app/endpoints/test_conversations_v3.py diff --git a/docs/devel_doc/openapi.json b/docs/devel_doc/openapi.json index 1eaaac8542..cbe06e6e8a 100644 --- a/docs/devel_doc/openapi.json +++ b/docs/devel_doc/openapi.json @@ -8776,84 +8776,35 @@ } } }, - "/v1/responses": { - "post": { + "/v3/conversations": { + "get": { "tags": [ - "responses" + "conversations_v3" ], - "summary": "Responses Endpoint Handler", - "description": "Handle request to the /responses endpoint using Responses API (LCORE specification).\n\nProcesses a POST request to the responses endpoint, forwarding the\nuser's request to a selected OGX LLM and returning the generated response\nfollowing the LCORE OpenAPI specification.\n\nReturns:\n ResponsesResponse: Contains the response following LCORE specification (non-streaming).\n StreamingResponse: SSE-formatted streaming response with enriched events (streaming).\n - response.created event includes conversation attribute\n - response.completed event includes available_quotas attribute\n\nRaises:\n HTTPException:\n - 401: Unauthorized - Missing or invalid credentials\n - 403: Forbidden - Insufficient permissions or model override not allowed\n - 404: Not Found - Conversation, model, or provider not found\n - 413: Prompt too long - Prompt exceeded model's context window size\n - 422: Unprocessable Entity - Request validation failed\n - 429: Quota limit exceeded - The token quota for model or user has been exceeded\n - 500: Internal Server Error - Configuration not loaded or other server errors\n - 503: Service Unavailable - Unable to connect to OGX backend", - "operationId": "responses_endpoint_handler_v1_responses_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ResponsesRequest" - } - } - }, - "required": true - }, + "summary": "Get Conversations List Endpoint Handler", + "description": "Handle request to retrieve all conversations for the authenticated user.\n\n### Parameters:\n- request: The incoming HTTP request (used by middleware).\n- auth: Auth context tuple resolved from the authentication dependency.\n\n### Returns:\n- AgenticConversationListResponse: Metadata for conversations visible to the caller.\n\n### Raises:\n- HTTPException:\n- 401: Unauthorized - Missing or invalid credentials\n- 403: Forbidden - Insufficient permissions\n- 500: Internal Server Error - Configuration not loaded or database failure\n- 503: Service Unavailable - Kubernetes API unavailable when required by auth", + "operationId": "get_conversations_list_endpoint_handler_v3_conversations_get", "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ResponsesResponse" + "$ref": "#/components/schemas/AgenticConversationListResponse" }, "example": { - "available_quotas": { - "daily": 1000, - "monthly": 50000 - }, - "completed_at": 1704067250, - "conversation": "0d21ba731f21f798dc9680125d5d6f493e4a7ab79f25670e", - "created_at": 1704067200, - "id": "resp_abc123", - "instructions": "You are a helpful assistant", - "model": "openai/gpt-4-turbo", - "object": "response", - "output": [ + "conversations": [ { - "content": [ - { - "text": "Kubernetes is an open-source container orchestration system...", - "type": "output_text" - } - ], - "role": "assistant", - "type": "message" - } - ], - "output_text": "Kubernetes is an open-source container orchestration system...", - "parallel_tool_calls": true, - "status": "completed", - "store": true, - "temperature": 0.7, - "text": { - "format": { - "type": "text" + "conversation_id": "123e4567-e89b-12d3-a456-426614174000", + "created_at": "2024-01-01T00:00:00Z", + "last_turn_at": "2024-01-01T00:01:05Z", + "last_used_model": "gpt-5.6-luna", + "last_used_provider": "openai", + "topic_summary": "OpenShift deployment strategies", + "turn_count": 1 } - }, - "usage": { - "input_tokens": 100, - "input_tokens_details": { - "cached_tokens": 0 - }, - "output_tokens": 50, - "output_tokens_details": { - "reasoning_tokens": 0 - }, - "total_tokens": 150 - } + ] } - }, - "text/event-stream": { - "schema": { - "type": "string" - }, - "example": "event: response.created\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"resp_abc\",\"object\":\"response\",\"created_at\":1704067200,\"status\":\"in_progress\",\"model\":\"openai/gpt-4o-mini\",\"output\":[],\"store\":true,\"text\":{\"format\":{\"type\":\"text\"}},\"conversation\":\"0d21ba731f21f798dc9680125d5d6f49\",\"available_quotas\":{},\"output_text\":\"\"}}\n\nevent: response.output_item.added\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":1,\"response_id\":\"resp_abc\",\"output_index\":0,\"item\":{\"id\":\"msg_abc\",\"type\":\"message\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]}}\n\n...\n\nevent: response.completed\ndata: {\"type\":\"response.completed\",\"sequence_number\":30,\"response\":{\"id\":\"resp_abc\",\"object\":\"response\",\"created_at\":1704067200,\"status\":\"completed\",\"model\":\"openai/gpt-4o-mini\",\"output\":[{\"id\":\"msg_abc\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Hello! How can I help?\",\"annotations\":[]}]}],\"store\":true,\"text\":{\"format\":{\"type\":\"text\"}},\"usage\":{\"input_tokens\":10,\"output_tokens\":6,\"total_tokens\":16,\"input_tokens_details\":{\"cached_tokens\":0},\"output_tokens_details\":{\"reasoning_tokens\":0}},\"conversation\":\"0d21ba731f21f798dc9680125d5d6f49\",\"available_quotas\":{\"daily\":1000,\"monthly\":50000},\"output_text\":\"Hello! How can I help?\"}}\n\ndata: [DONE]\n\n" } } }, @@ -8928,14 +8879,6 @@ "response": "Missing or invalid credentials provided by client" } } - }, - "mcp oauth": { - "value": { - "detail": { - "cause": "MCP server at https://mcp.example.com/v1 requires OAuth", - "response": "Missing or invalid credentials provided by client" - } - } } } } @@ -8949,14 +8892,6 @@ "$ref": "#/components/schemas/ForbiddenResponse" }, "examples": { - "conversation read": { - "value": { - "detail": { - "cause": "User 6789 does not have permission to read conversation with ID 123e4567-e89b-12d3-a456-426614174000", - "response": "User does not have permission to perform this action" - } - } - }, "endpoint": { "value": { "detail": { @@ -8964,48 +8899,32 @@ "response": "User does not have permission to access this endpoint" } } - }, - "model override": { - "value": { - "detail": { - "cause": "User lacks model_override permission required to override model/provider.", - "response": "This instance does not permit overriding model/provider in the query request (missing permission: model_override). Please remove the model and provider fields from your request." - } - } } } } } }, - "404": { - "description": "Resource not found", + "500": { + "description": "Internal server error", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/NotFoundResponse" + "$ref": "#/components/schemas/InternalServerErrorResponse" }, "examples": { - "conversation": { - "value": { - "detail": { - "cause": "Conversation with ID 123e4567-e89b-12d3-a456-426614174000 does not exist", - "response": "Conversation not found" - } - } - }, - "provider": { + "configuration": { "value": { "detail": { - "cause": "Provider with ID openai does not exist", - "response": "Provider not found" + "cause": "Lightspeed Stack configuration has not been initialized.", + "response": "Configuration is not loaded" } } }, - "model": { + "database operation": { "value": { "detail": { - "cause": "Model with ID gpt-5.6-luna does not exist", - "response": "Model not found" + "cause": "Failed to list conversations due to a database error.", + "response": "Database query failed" } } } @@ -9013,170 +8932,250 @@ } } }, - "409": { - "description": "Resource already exists", + "503": { + "description": "Service unavailable", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ConflictResponse" + "$ref": "#/components/schemas/ServiceUnavailableResponse" }, "examples": { - "mcp tool conflict": { - "value": { - "detail": { - "cause": "Client MCP tool with server_label 'my-server' conflicts with a server-configured MCP tool. Rename the client tool to avoid the conflict.", - "response": "Tool conflict" - } - } - }, - "file search conflict": { + "kubernetes api": { "value": { "detail": { - "cause": "Client file_search tool conflicts with a server-configured file_search tool. Remove the client file_search to use the server's configuration.", - "response": "Tool conflict" + "cause": "Failed to connect to Kubernetes API: Service Unavailable (status 503)", + "response": "Unable to connect to Kubernetes API" } } } } } } - }, - "413": { - "description": "Prompt is too long", + } + } + } + }, + "/v3/conversations/{conversation_id}": { + "get": { + "tags": [ + "conversations_v3" + ], + "summary": "Get Conversation Endpoint Handler", + "description": "Handle request to retrieve a conversation identified by its ID.\n\nLoads agent display history from persistence, including ordered agent turns.\n\n### Parameters:\n- request: The incoming HTTP request (used by middleware).\n- conversation_id: Unique identifier of the conversation to retrieve.\n- auth: Auth context tuple resolved from the authentication dependency.\n\n### Returns:\n- AgenticConversationGetResponse: Conversation metadata and agent turn history.\n\n### Raises:\n- HTTPException:\n- 400: Bad Request - Invalid conversation ID format\n- 401: Unauthorized - Missing or invalid credentials\n- 403: Forbidden - Insufficient permissions to read this conversation\n- 404: Not Found - Conversation does not exist\n- 500: Internal Server Error - Configuration not loaded or database failure\n- 503: Service Unavailable - Kubernetes API unavailable when required by auth", + "operationId": "get_conversation_endpoint_handler_v3_conversations__conversation_id__get", + "parameters": [ + { + "name": "conversation_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "title": "Conversation Id" + } + } + ], + "responses": { + "200": { + "description": "Successful response", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PromptTooLongResponse" + "$ref": "#/components/schemas/AgenticConversationGetResponse" }, + "example": { + "chat_history": [ + { + "completed_at": "2024-01-01T00:01:05Z", + "context_status": "full", + "id": "resp_1", + "input": [ + { + "content": [ + { + "text": "Hello", + "type": "text" + } + ], + "id": "msg_user_1", + "kind": "message", + "role": "user" + } + ], + "model": "gpt-5.6-luna", + "output": [ + { + "content": [ + { + "text": "Hi there!", + "type": "text" + } + ], + "id": "msg_assistant_1", + "kind": "message", + "role": "assistant" + } + ], + "provider": "openai", + "referenced_documents": [], + "started_at": "2024-01-01T00:01:00Z", + "status": "completed", + "usage": { + "input_tokens": 4, + "output_tokens": 6 + } + } + ], + "conversation_id": "123e4567-e89b-12d3-a456-426614174000", + "created_at": "2024-01-01T00:00:00Z", + "last_turn_at": "2024-01-01T00:01:05Z", + "last_used_model": "gpt-5.6-luna", + "last_used_provider": "openai", + "topic_summary": "OpenShift deployment strategies", + "turn_count": 1 + } + } + } + }, + "400": { + "description": "Invalid request format", + "content": { + "application/json": { "examples": { - "context window exceeded": { + "conversation_id": { "value": { "detail": { - "cause": "The input exceeds the context window size of model 'gpt-5.6-luna'.", - "response": "Context window exceeded" + "cause": "The conversation ID 123e4567-e89b-12d3-a456-426614174000 has invalid format.", + "response": "Invalid conversation ID format" } } } + }, + "schema": { + "$ref": "#/components/schemas/BadRequestResponse" } } } }, - "422": { - "description": "Request validation failed", + "401": { + "description": "Unauthorized", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/UnprocessableEntityResponse" - }, "examples": { - "invalid format": { + "missing header": { "value": { "detail": { - "cause": "Invalid request format. The request body could not be parsed.", - "response": "Invalid request format" + "cause": "No Authorization header found", + "response": "Missing or invalid credentials provided by client" } } }, - "missing attributes": { + "missing token": { "value": { "detail": { - "cause": "Missing required attributes: ['query', 'model', 'provider']", - "response": "Missing required attributes" + "cause": "No token found in Authorization header", + "response": "Missing or invalid credentials provided by client" } } }, - "invalid value": { + "expired token": { "value": { "detail": { - "cause": "Invalid attachment type: must be one of ['text/plain', 'application/json', 'application/yaml', 'application/xml']", - "response": "Invalid attribute value" + "cause": "Token has expired", + "response": "Missing or invalid credentials provided by client" } } }, - "saved prompt invalid": { + "invalid signature": { "value": { "detail": { - "cause": "Saved prompt name must not be empty", - "response": "Invalid attribute value" + "cause": "Invalid token signature", + "response": "Missing or invalid credentials provided by client" } } }, - "saved prompt limit": { + "invalid key": { "value": { "detail": { - "cause": "Saved prompt limit exceeded: 50 existing prompts, maximum is 50", - "response": "Saved prompt limit exceeded" + "cause": "Token signed by unknown key", + "response": "Missing or invalid credentials provided by client" } } - } - } - } - } - }, - "429": { - "description": "Quota limit exceeded", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/QuotaExceededResponse" - }, - "examples": { - "model": { + }, + "missing claim": { "value": { "detail": { - "cause": "The token quota for model gpt-4-turbo has been exceeded.", - "response": "The model quota has been exceeded" - } - } - }, - "user none": { - "value": { - "detail": { - "cause": "User 123 has no available tokens", - "response": "The quota has been exceeded" + "cause": "Token missing claim: user_id", + "response": "Missing or invalid credentials provided by client" } } }, - "cluster none": { + "invalid k8s token": { "value": { "detail": { - "cause": "Cluster has no available tokens", - "response": "The quota has been exceeded" + "cause": "Invalid or expired Kubernetes token", + "response": "Missing or invalid credentials provided by client" } } }, - "subject none": { + "invalid jwk token": { "value": { "detail": { - "cause": "Unknown subject 999 has no available tokens", - "response": "The quota has been exceeded" + "cause": "Authentication key server returned invalid data", + "response": "Missing or invalid credentials provided by client" } } - }, - "user insufficient": { + } + }, + "schema": { + "$ref": "#/components/schemas/UnauthorizedResponse" + } + } + } + }, + "403": { + "description": "Permission denied", + "content": { + "application/json": { + "examples": { + "conversation read": { "value": { "detail": { - "cause": "User 123 has 5 tokens, but 10 tokens are needed", - "response": "The quota has been exceeded" + "cause": "User 6789 does not have permission to read conversation with ID 123e4567-e89b-12d3-a456-426614174000", + "response": "User does not have permission to perform this action" } } }, - "cluster insufficient": { + "endpoint": { "value": { "detail": { - "cause": "Cluster has 500 tokens, but 900 tokens are needed", - "response": "The quota has been exceeded" + "cause": "User 6789 is not authorized to access this endpoint.", + "response": "User does not have permission to access this endpoint" } } - }, - "subject insufficient": { + } + }, + "schema": { + "$ref": "#/components/schemas/ForbiddenResponse" + } + } + } + }, + "404": { + "description": "Resource not found", + "content": { + "application/json": { + "examples": { + "conversation": { "value": { "detail": { - "cause": "Unknown subject 999 has 3 tokens, but 6 tokens are needed", - "response": "The quota has been exceeded" + "cause": "Conversation with ID 123e4567-e89b-12d3-a456-426614174000 does not exist", + "response": "Conversation not found" } } } + }, + "schema": { + "$ref": "#/components/schemas/NotFoundResponse" } } } @@ -9185,9 +9184,6 @@ "description": "Internal server error", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/InternalServerErrorResponse" - }, "examples": { "configuration": { "value": { @@ -9196,7 +9192,18 @@ "response": "Configuration is not loaded" } } + }, + "database operation": { + "value": { + "detail": { + "cause": "Failed to list conversations due to a database error.", + "response": "Database query failed" + } + } } + }, + "schema": { + "$ref": "#/components/schemas/InternalServerErrorResponse" } } } @@ -9205,18 +9212,7 @@ "description": "Service unavailable", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/ServiceUnavailableResponse" - }, "examples": { - "OGX": { - "value": { - "detail": { - "cause": "Connection error while trying to reach backend service.", - "response": "Unable to connect to OGX" - } - } - }, "kubernetes api": { "value": { "detail": { @@ -9225,44 +9221,86 @@ } } } + }, + "schema": { + "$ref": "#/components/schemas/ServiceUnavailableResponse" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" } } } } } - } - }, - "/v1/infer": { - "post": { + }, + "delete": { "tags": [ - "rlsapi-v1" + "conversations_v3" ], - "summary": "Infer Endpoint", - "description": "Handle rlsapi v1 /infer requests for stateless inference.\n\nThis endpoint serves requests from the RHEL Lightspeed Command Line Assistant (CLA).\n\nAccepts a question with optional context (stdin, attachments, terminal output,\nsystem info) and returns an LLM-generated response.\n\nArgs:\n infer_request: The inference request containing question and context.\n request: The FastAPI request object for accessing headers and state.\n background_tasks: FastAPI background tasks for async Splunk event sending.\n auth: Authentication tuple from the configured auth provider.\n\nReturns:\n RlsapiV1InferResponse containing the generated response text and request ID.\n\nRaises:\n HTTPException: 503 if the LLM service is unavailable.", - "operationId": "infer_endpoint_v1_infer_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RlsapiV1InferRequest" - } + "summary": "Delete Conversation Endpoint Handler", + "description": "Handle request to delete a conversation by ID.\n\n### Parameters:\n- request: The incoming HTTP request (used by middleware).\n- conversation_id: Unique identifier of the conversation to delete.\n- auth: Auth context tuple resolved from the authentication dependency.\n\n### Returns:\n- ConversationDeleteResponse: Whether the conversation was deleted.\n\n### Raises:\n- HTTPException:\n- 400: Bad Request - Invalid conversation ID format\n- 401: Unauthorized - Missing or invalid credentials\n- 403: Forbidden - Insufficient permissions to delete this conversation\n- 500: Internal Server Error - Configuration not loaded or database failure\n- 503: Service Unavailable - Kubernetes API unavailable when required by auth", + "operationId": "delete_conversation_endpoint_handler_v3_conversations__conversation_id__delete", + "parameters": [ + { + "name": "conversation_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "title": "Conversation Id" } - }, - "required": true - }, + } + ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RlsapiV1InferResponse" + "$ref": "#/components/schemas/ConversationDeleteResponse" }, - "example": { - "data": { - "request_id": "01JDKR8N7QW9ZMXVGK3PB5TQWZ", - "text": "To list files in Linux, use the `ls` command." + "examples": { + "deleted": { + "value": { + "conversation_id": "123e4567-e89b-12d3-a456-426614174000", + "deleted": true, + "response": "Conversation deleted successfully" + } + }, + "not found": { + "value": { + "conversation_id": "123e4567-e89b-12d3-a456-426614174000", + "deleted": false, + "response": "Conversation not found" + } + } + } + } + } + }, + "400": { + "description": "Invalid request format", + "content": { + "application/json": { + "examples": { + "conversation_id": { + "value": { + "detail": { + "cause": "The conversation ID 123e4567-e89b-12d3-a456-426614174000 has invalid format.", + "response": "Invalid conversation ID format" + } + } } + }, + "schema": { + "$ref": "#/components/schemas/BadRequestResponse" } } } @@ -9271,9 +9309,6 @@ "description": "Unauthorized", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/UnauthorizedResponse" - }, "examples": { "missing header": { "value": { @@ -9339,6 +9374,9 @@ } } } + }, + "schema": { + "$ref": "#/components/schemas/UnauthorizedResponse" } } } @@ -9347,10 +9385,15 @@ "description": "Permission denied", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/ForbiddenResponse" - }, "examples": { + "conversation delete": { + "value": { + "detail": { + "cause": "User 6789 does not have permission to delete conversation with ID 123e4567-e89b-12d3-a456-426614174000", + "response": "User does not have permission to perform this action" + } + } + }, "endpoint": { "value": { "detail": { @@ -9359,242 +9402,133 @@ } } } + }, + "schema": { + "$ref": "#/components/schemas/ForbiddenResponse" } } } }, - "404": { - "description": "Resource not found", + "500": { + "description": "Internal server error", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/NotFoundResponse" - }, "examples": { - "model": { + "configuration": { "value": { "detail": { - "cause": "Model with ID gpt-5.6-luna does not exist", - "response": "Model not found" + "cause": "Lightspeed Stack configuration has not been initialized.", + "response": "Configuration is not loaded" + } + } + }, + "database operation": { + "value": { + "detail": { + "cause": "Failed to list conversations due to a database error.", + "response": "Database query failed" } } } + }, + "schema": { + "$ref": "#/components/schemas/InternalServerErrorResponse" } } } }, - "413": { - "description": "Prompt is too long", + "503": { + "description": "Service unavailable", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/PromptTooLongResponse" - }, "examples": { - "context window exceeded": { + "kubernetes api": { "value": { "detail": { - "cause": "The input exceeds the context window size of model 'gpt-5.6-luna'.", - "response": "Context window exceeded" + "cause": "Failed to connect to Kubernetes API: Service Unavailable (status 503)", + "response": "Unable to connect to Kubernetes API" } } } + }, + "schema": { + "$ref": "#/components/schemas/ServiceUnavailableResponse" } } } }, "422": { - "description": "Request validation failed", + "description": "Validation Error", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/UnprocessableEntityResponse" - }, - "examples": { - "invalid format": { - "value": { - "detail": { - "cause": "Invalid request format. The request body could not be parsed.", - "response": "Invalid request format" - } - } - }, - "missing attributes": { - "value": { - "detail": { - "cause": "Missing required attributes: ['query', 'model', 'provider']", - "response": "Missing required attributes" - } - } - }, - "invalid value": { - "value": { - "detail": { - "cause": "Invalid attachment type: must be one of ['text/plain', 'application/json', 'application/yaml', 'application/xml']", - "response": "Invalid attribute value" - } - } - }, - "saved prompt invalid": { - "value": { - "detail": { - "cause": "Saved prompt name must not be empty", - "response": "Invalid attribute value" - } - } - }, - "saved prompt limit": { - "value": { - "detail": { - "cause": "Saved prompt limit exceeded: 50 existing prompts, maximum is 50", - "response": "Saved prompt limit exceeded" - } - } - } + "$ref": "#/components/schemas/HTTPValidationError" } } } - }, - "429": { - "description": "Quota limit exceeded", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/QuotaExceededResponse" - }, - "examples": { - "model": { - "value": { - "detail": { - "cause": "The token quota for model gpt-4-turbo has been exceeded.", - "response": "The model quota has been exceeded" - } - } - }, - "user none": { - "value": { - "detail": { - "cause": "User 123 has no available tokens", - "response": "The quota has been exceeded" - } - } - }, - "cluster none": { - "value": { - "detail": { - "cause": "Cluster has no available tokens", - "response": "The quota has been exceeded" - } - } - }, - "subject none": { - "value": { - "detail": { - "cause": "Unknown subject 999 has no available tokens", - "response": "The quota has been exceeded" - } - } - }, - "user insufficient": { - "value": { - "detail": { - "cause": "User 123 has 5 tokens, but 10 tokens are needed", - "response": "The quota has been exceeded" - } - } - }, - "cluster insufficient": { - "value": { - "detail": { - "cause": "Cluster has 500 tokens, but 900 tokens are needed", - "response": "The quota has been exceeded" - } - } - }, - "subject insufficient": { - "value": { - "detail": { - "cause": "Unknown subject 999 has 3 tokens, but 6 tokens are needed", - "response": "The quota has been exceeded" - } - } - } - } + } + } + }, + "put": { + "tags": [ + "conversations_v3" + ], + "summary": "Update Conversation Endpoint Handler", + "description": "Handle request to update a conversation topic summary by ID.\n\n### Parameters:\n- request: The incoming HTTP request (used by middleware).\n- conversation_id: Unique identifier of the conversation to update.\n- update_request: Request body containing the new topic summary.\n- auth: Auth context tuple resolved from the authentication dependency.\n\n### Returns:\n- ConversationUpdateResponse: Result of the update operation.\n\n### Raises:\n- HTTPException:\n- 400: Bad Request - Invalid conversation ID format\n- 401: Unauthorized - Missing or invalid credentials\n- 403: Forbidden - Insufficient permissions to update this conversation\n- 404: Not Found - Conversation does not exist\n- 500: Internal Server Error - Configuration not loaded or database failure\n- 503: Service Unavailable - Kubernetes API unavailable when required by auth", + "operationId": "update_conversation_endpoint_handler_v3_conversations__conversation_id__put", + "parameters": [ + { + "name": "conversation_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "title": "Conversation Id" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConversationUpdateRequest" } } - }, - "500": { - "description": "Internal server error", + } + }, + "responses": { + "200": { + "description": "Successful response", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/InternalServerErrorResponse" + "$ref": "#/components/schemas/ConversationUpdateResponse" }, - "examples": { - "configuration": { - "value": { - "detail": { - "cause": "Lightspeed Stack configuration has not been initialized.", - "response": "Configuration is not loaded" - } - } - } + "example": { + "conversation_id": "123e4567-e89b-12d3-a456-426614174000", + "message": "Topic summary updated successfully", + "success": true } } } }, - "503": { - "description": "Service unavailable", + "400": { + "description": "Invalid request format", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/ServiceUnavailableResponse" - }, "examples": { - "OGX": { - "value": { - "detail": { - "cause": "Connection error while trying to reach backend service.", - "response": "Unable to connect to OGX" - } - } - }, - "kubernetes api": { + "conversation_id": { "value": { "detail": { - "cause": "Failed to connect to Kubernetes API: Service Unavailable (status 503)", - "response": "Unable to connect to Kubernetes API" + "cause": "The conversation ID 123e4567-e89b-12d3-a456-426614174000 has invalid format.", + "response": "Invalid conversation ID format" } } } - } - } - } - } - } - } - }, - "/readiness": { - "get": { - "tags": [ - "health" - ], - "summary": "Readiness Probe Get Method", - "description": "Handle the readiness probe endpoint, returning service readiness and health status.\n\nReturns comprehensive health information including overall service status,\nprovider health, and functional impacts.\n\n### Parameters:\n- response: The outgoing HTTP response (used by middleware).\n- auth: Authentication tuple from the auth dependency (used by middleware).\n\n### Raises:\n- HTTPException: with status 401 for unauthorized access.\n- HTTPException: with status 403 if permission is denied.\n- HTTPException: with status 503 when service is unhealthy (providers down,\n models unavailable).\n\n### Returns:\n- ReadinessResponse: Object with comprehensive health status including:\n - ready: True if service can handle requests\n - reason: Description of service state\n - overall_status: healthy or unhealthy\n - impacts: Functional limitations when unhealthy\n - providers: List of unhealthy providers", - "operationId": "readiness_probe_get_method_readiness_get", - "responses": { - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ReadinessResponse" }, - "example": { - "overall_status": "healthy", - "providers": [], - "ready": true, - "reason": "All providers are healthy" + "schema": { + "$ref": "#/components/schemas/BadRequestResponse" } } } @@ -9603,9 +9537,6 @@ "description": "Unauthorized", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/UnauthorizedResponse" - }, "examples": { "missing header": { "value": { @@ -9671,6 +9602,9 @@ } } } + }, + "schema": { + "$ref": "#/components/schemas/UnauthorizedResponse" } } } @@ -9679,9 +9613,6 @@ "description": "Permission denied", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/ForbiddenResponse" - }, "examples": { "endpoint": { "value": { @@ -9691,26 +9622,66 @@ } } } + }, + "schema": { + "$ref": "#/components/schemas/ForbiddenResponse" } } } }, - "503": { - "description": "Service unavailable", + "404": { + "description": "Resource not found", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/ServiceUnavailableResponse" + "examples": { + "conversation": { + "value": { + "detail": { + "cause": "Conversation with ID 123e4567-e89b-12d3-a456-426614174000 does not exist", + "response": "Conversation not found" + } + } + } }, + "schema": { + "$ref": "#/components/schemas/NotFoundResponse" + } + } + } + }, + "500": { + "description": "Internal server error", + "content": { + "application/json": { "examples": { - "OGX": { + "configuration": { "value": { "detail": { - "cause": "Connection error while trying to reach backend service.", - "response": "Unable to connect to OGX" + "cause": "Lightspeed Stack configuration has not been initialized.", + "response": "Configuration is not loaded" } } }, + "database operation": { + "value": { + "detail": { + "cause": "Failed to list conversations due to a database error.", + "response": "Database query failed" + } + } + } + }, + "schema": { + "$ref": "#/components/schemas/InternalServerErrorResponse" + } + } + } + }, + "503": { + "description": "Service unavailable", + "content": { + "application/json": { + "examples": { "kubernetes api": { "value": { "detail": { @@ -9719,32 +9690,104 @@ } } } + }, + "schema": { + "$ref": "#/components/schemas/ServiceUnavailableResponse" } } } - } - } - } - }, - "/liveness": { - "get": { - "tags": [ - "health" + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/v1/responses": { + "post": { + "tags": [ + "responses" ], - "summary": "Liveness Probe Get Method", - "description": "Return the liveness status of the service.\n\n### Parameters:\n- auth: Authentication tuple from the auth dependency (used by middleware).\n\n### Raises:\n- HTTPException: with status 401 for unauthorized access.\n- HTTPException: with status 403 if permission is denied.\n- HTTPException: with status 500 and a detail object containing `response`\n and `cause` when service configuration is wrong or incomplete.\n- HTTPException: with status 503 and a detail object containing `response`\n and `cause` when unable to connect to OGX.\n\n### Returns:\n- LivenessResponse: Indicates that the service is alive.", - "operationId": "liveness_probe_get_method_liveness_get", + "summary": "Responses Endpoint Handler", + "description": "Handle request to the /responses endpoint using Responses API (LCORE specification).\n\nProcesses a POST request to the responses endpoint, forwarding the\nuser's request to a selected OGX LLM and returning the generated response\nfollowing the LCORE OpenAPI specification.\n\nReturns:\n ResponsesResponse: Contains the response following LCORE specification (non-streaming).\n StreamingResponse: SSE-formatted streaming response with enriched events (streaming).\n - response.created event includes conversation attribute\n - response.completed event includes available_quotas attribute\n\nRaises:\n HTTPException:\n - 401: Unauthorized - Missing or invalid credentials\n - 403: Forbidden - Insufficient permissions or model override not allowed\n - 404: Not Found - Conversation, model, or provider not found\n - 413: Prompt too long - Prompt exceeded model's context window size\n - 422: Unprocessable Entity - Request validation failed\n - 429: Quota limit exceeded - The token quota for model or user has been exceeded\n - 500: Internal Server Error - Configuration not loaded or other server errors\n - 503: Service Unavailable - Unable to connect to OGX backend", + "operationId": "responses_endpoint_handler_v1_responses_post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ResponsesRequest" + } + } + }, + "required": true + }, "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/LivenessResponse" + "$ref": "#/components/schemas/ResponsesResponse" }, "example": { - "alive": true + "available_quotas": { + "daily": 1000, + "monthly": 50000 + }, + "completed_at": 1704067250, + "conversation": "0d21ba731f21f798dc9680125d5d6f493e4a7ab79f25670e", + "created_at": 1704067200, + "id": "resp_abc123", + "instructions": "You are a helpful assistant", + "model": "openai/gpt-4-turbo", + "object": "response", + "output": [ + { + "content": [ + { + "text": "Kubernetes is an open-source container orchestration system...", + "type": "output_text" + } + ], + "role": "assistant", + "type": "message" + } + ], + "output_text": "Kubernetes is an open-source container orchestration system...", + "parallel_tool_calls": true, + "status": "completed", + "store": true, + "temperature": 0.7, + "text": { + "format": { + "type": "text" + } + }, + "usage": { + "input_tokens": 100, + "input_tokens_details": { + "cached_tokens": 0 + }, + "output_tokens": 50, + "output_tokens_details": { + "reasoning_tokens": 0 + }, + "total_tokens": 150 + } } + }, + "text/event-stream": { + "schema": { + "type": "string" + }, + "example": "event: response.created\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"resp_abc\",\"object\":\"response\",\"created_at\":1704067200,\"status\":\"in_progress\",\"model\":\"openai/gpt-4o-mini\",\"output\":[],\"store\":true,\"text\":{\"format\":{\"type\":\"text\"}},\"conversation\":\"0d21ba731f21f798dc9680125d5d6f49\",\"available_quotas\":{},\"output_text\":\"\"}}\n\nevent: response.output_item.added\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":1,\"response_id\":\"resp_abc\",\"output_index\":0,\"item\":{\"id\":\"msg_abc\",\"type\":\"message\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]}}\n\n...\n\nevent: response.completed\ndata: {\"type\":\"response.completed\",\"sequence_number\":30,\"response\":{\"id\":\"resp_abc\",\"object\":\"response\",\"created_at\":1704067200,\"status\":\"completed\",\"model\":\"openai/gpt-4o-mini\",\"output\":[{\"id\":\"msg_abc\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Hello! How can I help?\",\"annotations\":[]}]}],\"store\":true,\"text\":{\"format\":{\"type\":\"text\"}},\"usage\":{\"input_tokens\":10,\"output_tokens\":6,\"total_tokens\":16,\"input_tokens_details\":{\"cached_tokens\":0},\"output_tokens_details\":{\"reasoning_tokens\":0}},\"conversation\":\"0d21ba731f21f798dc9680125d5d6f49\",\"available_quotas\":{\"daily\":1000,\"monthly\":50000},\"output_text\":\"Hello! How can I help?\"}}\n\ndata: [DONE]\n\n" } } }, @@ -9819,6 +9862,14 @@ "response": "Missing or invalid credentials provided by client" } } + }, + "mcp oauth": { + "value": { + "detail": { + "cause": "MCP server at https://mcp.example.com/v1 requires OAuth", + "response": "Missing or invalid credentials provided by client" + } + } } } } @@ -9832,6 +9883,14 @@ "$ref": "#/components/schemas/ForbiddenResponse" }, "examples": { + "conversation read": { + "value": { + "detail": { + "cause": "User 6789 does not have permission to read conversation with ID 123e4567-e89b-12d3-a456-426614174000", + "response": "User does not have permission to perform this action" + } + } + }, "endpoint": { "value": { "detail": { @@ -9839,127 +9898,148 @@ "response": "User does not have permission to access this endpoint" } } + }, + "model override": { + "value": { + "detail": { + "cause": "User lacks model_override permission required to override model/provider.", + "response": "This instance does not permit overriding model/provider in the query request (missing permission: model_override). Please remove the model and provider fields from your request." + } + } } } } } }, - "503": { - "description": "Service unavailable", + "404": { + "description": "Resource not found", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ServiceUnavailableResponse" + "$ref": "#/components/schemas/NotFoundResponse" }, "examples": { - "kubernetes api": { + "conversation": { "value": { "detail": { - "cause": "Failed to connect to Kubernetes API: Service Unavailable (status 503)", - "response": "Unable to connect to Kubernetes API" + "cause": "Conversation with ID 123e4567-e89b-12d3-a456-426614174000 does not exist", + "response": "Conversation not found" + } + } + }, + "provider": { + "value": { + "detail": { + "cause": "Provider with ID openai does not exist", + "response": "Provider not found" + } + } + }, + "model": { + "value": { + "detail": { + "cause": "Model with ID gpt-5.6-luna does not exist", + "response": "Model not found" } } } } } } - } - } - } - }, - "/authorized": { - "post": { - "tags": [ - "authorized" - ], - "summary": "Authorized Endpoint Handler", - "description": "Handle request to the /authorized endpoint.\n\nProcess POST requests to the /authorized endpoint, returning\nthe authenticated user's ID and username.\n\nThe response intentionally omits any authentication token.\n\n### Parameters:\n- auth: Authentication tuple from the auth dependency (used by middleware).\n\n### Returns:\n- AuthorizedResponse: Contains the user ID and username of the authenticated user.", - "operationId": "authorized_endpoint_handler_authorized_post", - "responses": { - "200": { - "description": "Successful response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AuthorizedResponse" - }, - "example": { - "skip_userid_check": false, - "user_id": "123e4567-e89b-12d3-a456-426614174000", - "username": "user1" - } - } - } }, - "401": { - "description": "Unauthorized", + "409": { + "description": "Resource already exists", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/UnauthorizedResponse" + "$ref": "#/components/schemas/ConflictResponse" }, "examples": { - "missing header": { + "mcp tool conflict": { "value": { "detail": { - "cause": "No Authorization header found", - "response": "Missing or invalid credentials provided by client" + "cause": "Client MCP tool with server_label 'my-server' conflicts with a server-configured MCP tool. Rename the client tool to avoid the conflict.", + "response": "Tool conflict" } } }, - "missing token": { + "file search conflict": { "value": { "detail": { - "cause": "No token found in Authorization header", - "response": "Missing or invalid credentials provided by client" + "cause": "Client file_search tool conflicts with a server-configured file_search tool. Remove the client file_search to use the server's configuration.", + "response": "Tool conflict" } } - }, - "expired token": { + } + } + } + } + }, + "413": { + "description": "Prompt is too long", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PromptTooLongResponse" + }, + "examples": { + "context window exceeded": { "value": { "detail": { - "cause": "Token has expired", - "response": "Missing or invalid credentials provided by client" + "cause": "The input exceeds the context window size of model 'gpt-5.6-luna'.", + "response": "Context window exceeded" } } - }, - "invalid signature": { + } + } + } + } + }, + "422": { + "description": "Request validation failed", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnprocessableEntityResponse" + }, + "examples": { + "invalid format": { "value": { "detail": { - "cause": "Invalid token signature", - "response": "Missing or invalid credentials provided by client" + "cause": "Invalid request format. The request body could not be parsed.", + "response": "Invalid request format" } } }, - "invalid key": { + "missing attributes": { "value": { "detail": { - "cause": "Token signed by unknown key", - "response": "Missing or invalid credentials provided by client" + "cause": "Missing required attributes: ['query', 'model', 'provider']", + "response": "Missing required attributes" } } }, - "missing claim": { + "invalid value": { "value": { "detail": { - "cause": "Token missing claim: user_id", - "response": "Missing or invalid credentials provided by client" + "cause": "Invalid attachment type: must be one of ['text/plain', 'application/json', 'application/yaml', 'application/xml']", + "response": "Invalid attribute value" } } }, - "invalid k8s token": { + "saved prompt invalid": { "value": { "detail": { - "cause": "Invalid or expired Kubernetes token", - "response": "Missing or invalid credentials provided by client" + "cause": "Saved prompt name must not be empty", + "response": "Invalid attribute value" } } }, - "invalid jwk token": { + "saved prompt limit": { "value": { "detail": { - "cause": "Authentication key server returned invalid data", - "response": "Missing or invalid credentials provided by client" + "cause": "Saved prompt limit exceeded: 50 existing prompts, maximum is 50", + "response": "Saved prompt limit exceeded" } } } @@ -9967,19 +10047,87 @@ } } }, - "403": { - "description": "Permission denied", + "429": { + "description": "Quota limit exceeded", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ForbiddenResponse" + "$ref": "#/components/schemas/QuotaExceededResponse" }, "examples": { - "endpoint": { + "model": { "value": { "detail": { - "cause": "User 6789 is not authorized to access this endpoint.", - "response": "User does not have permission to access this endpoint" + "cause": "The token quota for model gpt-4-turbo has been exceeded.", + "response": "The model quota has been exceeded" + } + } + }, + "user none": { + "value": { + "detail": { + "cause": "User 123 has no available tokens", + "response": "The quota has been exceeded" + } + } + }, + "cluster none": { + "value": { + "detail": { + "cause": "Cluster has no available tokens", + "response": "The quota has been exceeded" + } + } + }, + "subject none": { + "value": { + "detail": { + "cause": "Unknown subject 999 has no available tokens", + "response": "The quota has been exceeded" + } + } + }, + "user insufficient": { + "value": { + "detail": { + "cause": "User 123 has 5 tokens, but 10 tokens are needed", + "response": "The quota has been exceeded" + } + } + }, + "cluster insufficient": { + "value": { + "detail": { + "cause": "Cluster has 500 tokens, but 900 tokens are needed", + "response": "The quota has been exceeded" + } + } + }, + "subject insufficient": { + "value": { + "detail": { + "cause": "Unknown subject 999 has 3 tokens, but 6 tokens are needed", + "response": "The quota has been exceeded" + } + } + } + } + } + } + }, + "500": { + "description": "Internal server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InternalServerErrorResponse" + }, + "examples": { + "configuration": { + "value": { + "detail": { + "cause": "Lightspeed Stack configuration has not been initialized.", + "response": "Configuration is not loaded" } } } @@ -9995,6 +10143,14 @@ "$ref": "#/components/schemas/ServiceUnavailableResponse" }, "examples": { + "OGX": { + "value": { + "detail": { + "cause": "Connection error while trying to reach backend service.", + "response": "Unable to connect to OGX" + } + } + }, "kubernetes api": { "value": { "detail": { @@ -10010,21 +10166,37 @@ } } }, - "/metrics": { - "get": { + "/v1/infer": { + "post": { "tags": [ - "metrics" + "rlsapi-v1" ], - "summary": "Metrics Endpoint Handler", - "description": "Handle request to the /metrics endpoint.\n\nProcess GET requests to the /metrics endpoint, returning the\nlatest Prometheus metrics in plain text Prometheus format.\n\n### Parameters:\n- request: The incoming HTTP request (used by middleware).\n- auth: Authentication tuple from the auth dependency (used by middleware).\n\n### Returns:\n- PlainTextResponse: Response body containing the Prometheus metrics text\n and the Prometheus content type.", - "operationId": "metrics_endpoint_handler_metrics_get", + "summary": "Infer Endpoint", + "description": "Handle rlsapi v1 /infer requests for stateless inference.\n\nThis endpoint serves requests from the RHEL Lightspeed Command Line Assistant (CLA).\n\nAccepts a question with optional context (stdin, attachments, terminal output,\nsystem info) and returns an LLM-generated response.\n\nArgs:\n infer_request: The inference request containing question and context.\n request: The FastAPI request object for accessing headers and state.\n background_tasks: FastAPI background tasks for async Splunk event sending.\n auth: Authentication tuple from the configured auth provider.\n\nReturns:\n RlsapiV1InferResponse containing the generated response text and request ID.\n\nRaises:\n HTTPException: 503 if the LLM service is unavailable.", + "operationId": "infer_endpoint_v1_infer_post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RlsapiV1InferRequest" + } + } + }, + "required": true + }, "responses": { "200": { - "description": "Successful Response", + "description": "Successful response", "content": { - "text/plain": { + "application/json": { "schema": { - "type": "string" + "$ref": "#/components/schemas/RlsapiV1InferResponse" + }, + "example": { + "data": { + "request_id": "01JDKR8N7QW9ZMXVGK3PB5TQWZ", + "text": "To list files in Linux, use the `ls` command." + } } } } @@ -10033,6 +10205,9 @@ "description": "Unauthorized", "content": { "application/json": { + "schema": { + "$ref": "#/components/schemas/UnauthorizedResponse" + }, "examples": { "missing header": { "value": { @@ -10099,11 +10274,6 @@ } } } - }, - "text/plain": { - "schema": { - "$ref": "#/components/schemas/UnauthorizedResponse" - } } } }, @@ -10111,6 +10281,9 @@ "description": "Permission denied", "content": { "application/json": { + "schema": { + "$ref": "#/components/schemas/ForbiddenResponse" + }, "examples": { "endpoint": { "value": { @@ -10121,108 +10294,869 @@ } } } - }, - "text/plain": { - "schema": { - "$ref": "#/components/schemas/ForbiddenResponse" - } } } }, - "500": { - "description": "Internal server error", + "404": { + "description": "Resource not found", "content": { "application/json": { + "schema": { + "$ref": "#/components/schemas/NotFoundResponse" + }, "examples": { - "configuration": { + "model": { "value": { "detail": { - "cause": "Lightspeed Stack configuration has not been initialized.", - "response": "Configuration is not loaded" + "cause": "Model with ID gpt-5.6-luna does not exist", + "response": "Model not found" } } } } - }, - "text/plain": { + } + } + }, + "413": { + "description": "Prompt is too long", + "content": { + "application/json": { "schema": { - "$ref": "#/components/schemas/InternalServerErrorResponse" + "$ref": "#/components/schemas/PromptTooLongResponse" + }, + "examples": { + "context window exceeded": { + "value": { + "detail": { + "cause": "The input exceeds the context window size of model 'gpt-5.6-luna'.", + "response": "Context window exceeded" + } + } + } } } } }, - "503": { - "description": "Service unavailable", + "422": { + "description": "Request validation failed", "content": { "application/json": { + "schema": { + "$ref": "#/components/schemas/UnprocessableEntityResponse" + }, "examples": { - "OGX": { + "invalid format": { "value": { "detail": { - "cause": "Connection error while trying to reach backend service.", - "response": "Unable to connect to OGX" + "cause": "Invalid request format. The request body could not be parsed.", + "response": "Invalid request format" } } }, - "kubernetes api": { + "missing attributes": { "value": { "detail": { - "cause": "Failed to connect to Kubernetes API: Service Unavailable (status 503)", - "response": "Unable to connect to Kubernetes API" + "cause": "Missing required attributes: ['query', 'model', 'provider']", + "response": "Missing required attributes" + } + } + }, + "invalid value": { + "value": { + "detail": { + "cause": "Invalid attachment type: must be one of ['text/plain', 'application/json', 'application/yaml', 'application/xml']", + "response": "Invalid attribute value" + } + } + }, + "saved prompt invalid": { + "value": { + "detail": { + "cause": "Saved prompt name must not be empty", + "response": "Invalid attribute value" + } + } + }, + "saved prompt limit": { + "value": { + "detail": { + "cause": "Saved prompt limit exceeded: 50 existing prompts, maximum is 50", + "response": "Saved prompt limit exceeded" } } } } - }, - "text/plain": { - "schema": { - "$ref": "#/components/schemas/ServiceUnavailableResponse" - } - } - } - } - } - } - }, - "/.well-known/agent-card.json": { - "get": { - "tags": [ - "a2a" - ], - "summary": "Get Agent Card", - "description": "Serve the A2A Agent Card at the well-known location.\n\nThis endpoint provides the agent card that describes Lightspeed's\ncapabilities according to the A2A protocol specification.\n\n### Parameters:\n- auth: Authentication tuple from the auth dependency (used by middleware).\n\n### Raises:\n- HTTPException: with status 500 and a detail object containing `response`\n and `cause` when service configuration is wrong or incomplete.\n- HTTPException: with status 503 and a detail object containing `response`\n and `cause` when unable to connect to OGX.\n\n### Returns:\n- AgentCard: The agent card describing this agent's capabilities.", - "operationId": "get_agent_card__well_known_agent_card_json_get", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AgentCard" - } } } - } - } - } - }, - "/.well-known/agent.json": { - "get": { - "tags": [ - "a2a" - ], - "summary": "Get Agent Card", - "description": "Serve the A2A Agent Card at the well-known location.\n\nThis endpoint provides the agent card that describes Lightspeed's\ncapabilities according to the A2A protocol specification.\n\n### Parameters:\n- auth: Authentication tuple from the auth dependency (used by middleware).\n\n### Raises:\n- HTTPException: with status 500 and a detail object containing `response`\n and `cause` when service configuration is wrong or incomplete.\n- HTTPException: with status 503 and a detail object containing `response`\n and `cause` when unable to connect to OGX.\n\n### Returns:\n- AgentCard: The agent card describing this agent's capabilities.", - "operationId": "get_agent_card__well_known_agent_json_get", - "responses": { - "200": { - "description": "Successful Response", + }, + "429": { + "description": "Quota limit exceeded", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AgentCard" - } - } + "$ref": "#/components/schemas/QuotaExceededResponse" + }, + "examples": { + "model": { + "value": { + "detail": { + "cause": "The token quota for model gpt-4-turbo has been exceeded.", + "response": "The model quota has been exceeded" + } + } + }, + "user none": { + "value": { + "detail": { + "cause": "User 123 has no available tokens", + "response": "The quota has been exceeded" + } + } + }, + "cluster none": { + "value": { + "detail": { + "cause": "Cluster has no available tokens", + "response": "The quota has been exceeded" + } + } + }, + "subject none": { + "value": { + "detail": { + "cause": "Unknown subject 999 has no available tokens", + "response": "The quota has been exceeded" + } + } + }, + "user insufficient": { + "value": { + "detail": { + "cause": "User 123 has 5 tokens, but 10 tokens are needed", + "response": "The quota has been exceeded" + } + } + }, + "cluster insufficient": { + "value": { + "detail": { + "cause": "Cluster has 500 tokens, but 900 tokens are needed", + "response": "The quota has been exceeded" + } + } + }, + "subject insufficient": { + "value": { + "detail": { + "cause": "Unknown subject 999 has 3 tokens, but 6 tokens are needed", + "response": "The quota has been exceeded" + } + } + } + } + } + } + }, + "500": { + "description": "Internal server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InternalServerErrorResponse" + }, + "examples": { + "configuration": { + "value": { + "detail": { + "cause": "Lightspeed Stack configuration has not been initialized.", + "response": "Configuration is not loaded" + } + } + } + } + } + } + }, + "503": { + "description": "Service unavailable", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ServiceUnavailableResponse" + }, + "examples": { + "OGX": { + "value": { + "detail": { + "cause": "Connection error while trying to reach backend service.", + "response": "Unable to connect to OGX" + } + } + }, + "kubernetes api": { + "value": { + "detail": { + "cause": "Failed to connect to Kubernetes API: Service Unavailable (status 503)", + "response": "Unable to connect to Kubernetes API" + } + } + } + } + } + } + } + } + } + }, + "/readiness": { + "get": { + "tags": [ + "health" + ], + "summary": "Readiness Probe Get Method", + "description": "Handle the readiness probe endpoint, returning service readiness and health status.\n\nReturns comprehensive health information including overall service status,\nprovider health, and functional impacts.\n\n### Parameters:\n- response: The outgoing HTTP response (used by middleware).\n- auth: Authentication tuple from the auth dependency (used by middleware).\n\n### Raises:\n- HTTPException: with status 401 for unauthorized access.\n- HTTPException: with status 403 if permission is denied.\n- HTTPException: with status 503 when service is unhealthy (providers down,\n models unavailable).\n\n### Returns:\n- ReadinessResponse: Object with comprehensive health status including:\n - ready: True if service can handle requests\n - reason: Description of service state\n - overall_status: healthy or unhealthy\n - impacts: Functional limitations when unhealthy\n - providers: List of unhealthy providers", + "operationId": "readiness_probe_get_method_readiness_get", + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ReadinessResponse" + }, + "example": { + "overall_status": "healthy", + "providers": [], + "ready": true, + "reason": "All providers are healthy" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnauthorizedResponse" + }, + "examples": { + "missing header": { + "value": { + "detail": { + "cause": "No Authorization header found", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "missing token": { + "value": { + "detail": { + "cause": "No token found in Authorization header", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "expired token": { + "value": { + "detail": { + "cause": "Token has expired", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid signature": { + "value": { + "detail": { + "cause": "Invalid token signature", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid key": { + "value": { + "detail": { + "cause": "Token signed by unknown key", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "missing claim": { + "value": { + "detail": { + "cause": "Token missing claim: user_id", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid k8s token": { + "value": { + "detail": { + "cause": "Invalid or expired Kubernetes token", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid jwk token": { + "value": { + "detail": { + "cause": "Authentication key server returned invalid data", + "response": "Missing or invalid credentials provided by client" + } + } + } + } + } + } + }, + "403": { + "description": "Permission denied", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ForbiddenResponse" + }, + "examples": { + "endpoint": { + "value": { + "detail": { + "cause": "User 6789 is not authorized to access this endpoint.", + "response": "User does not have permission to access this endpoint" + } + } + } + } + } + } + }, + "503": { + "description": "Service unavailable", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ServiceUnavailableResponse" + }, + "examples": { + "OGX": { + "value": { + "detail": { + "cause": "Connection error while trying to reach backend service.", + "response": "Unable to connect to OGX" + } + } + }, + "kubernetes api": { + "value": { + "detail": { + "cause": "Failed to connect to Kubernetes API: Service Unavailable (status 503)", + "response": "Unable to connect to Kubernetes API" + } + } + } + } + } + } + } + } + } + }, + "/liveness": { + "get": { + "tags": [ + "health" + ], + "summary": "Liveness Probe Get Method", + "description": "Return the liveness status of the service.\n\n### Parameters:\n- auth: Authentication tuple from the auth dependency (used by middleware).\n\n### Raises:\n- HTTPException: with status 401 for unauthorized access.\n- HTTPException: with status 403 if permission is denied.\n- HTTPException: with status 500 and a detail object containing `response`\n and `cause` when service configuration is wrong or incomplete.\n- HTTPException: with status 503 and a detail object containing `response`\n and `cause` when unable to connect to OGX.\n\n### Returns:\n- LivenessResponse: Indicates that the service is alive.", + "operationId": "liveness_probe_get_method_liveness_get", + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LivenessResponse" + }, + "example": { + "alive": true + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnauthorizedResponse" + }, + "examples": { + "missing header": { + "value": { + "detail": { + "cause": "No Authorization header found", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "missing token": { + "value": { + "detail": { + "cause": "No token found in Authorization header", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "expired token": { + "value": { + "detail": { + "cause": "Token has expired", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid signature": { + "value": { + "detail": { + "cause": "Invalid token signature", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid key": { + "value": { + "detail": { + "cause": "Token signed by unknown key", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "missing claim": { + "value": { + "detail": { + "cause": "Token missing claim: user_id", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid k8s token": { + "value": { + "detail": { + "cause": "Invalid or expired Kubernetes token", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid jwk token": { + "value": { + "detail": { + "cause": "Authentication key server returned invalid data", + "response": "Missing or invalid credentials provided by client" + } + } + } + } + } + } + }, + "403": { + "description": "Permission denied", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ForbiddenResponse" + }, + "examples": { + "endpoint": { + "value": { + "detail": { + "cause": "User 6789 is not authorized to access this endpoint.", + "response": "User does not have permission to access this endpoint" + } + } + } + } + } + } + }, + "503": { + "description": "Service unavailable", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ServiceUnavailableResponse" + }, + "examples": { + "kubernetes api": { + "value": { + "detail": { + "cause": "Failed to connect to Kubernetes API: Service Unavailable (status 503)", + "response": "Unable to connect to Kubernetes API" + } + } + } + } + } + } + } + } + } + }, + "/authorized": { + "post": { + "tags": [ + "authorized" + ], + "summary": "Authorized Endpoint Handler", + "description": "Handle request to the /authorized endpoint.\n\nProcess POST requests to the /authorized endpoint, returning\nthe authenticated user's ID and username.\n\nThe response intentionally omits any authentication token.\n\n### Parameters:\n- auth: Authentication tuple from the auth dependency (used by middleware).\n\n### Returns:\n- AuthorizedResponse: Contains the user ID and username of the authenticated user.", + "operationId": "authorized_endpoint_handler_authorized_post", + "responses": { + "200": { + "description": "Successful response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthorizedResponse" + }, + "example": { + "skip_userid_check": false, + "user_id": "123e4567-e89b-12d3-a456-426614174000", + "username": "user1" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnauthorizedResponse" + }, + "examples": { + "missing header": { + "value": { + "detail": { + "cause": "No Authorization header found", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "missing token": { + "value": { + "detail": { + "cause": "No token found in Authorization header", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "expired token": { + "value": { + "detail": { + "cause": "Token has expired", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid signature": { + "value": { + "detail": { + "cause": "Invalid token signature", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid key": { + "value": { + "detail": { + "cause": "Token signed by unknown key", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "missing claim": { + "value": { + "detail": { + "cause": "Token missing claim: user_id", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid k8s token": { + "value": { + "detail": { + "cause": "Invalid or expired Kubernetes token", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid jwk token": { + "value": { + "detail": { + "cause": "Authentication key server returned invalid data", + "response": "Missing or invalid credentials provided by client" + } + } + } + } + } + } + }, + "403": { + "description": "Permission denied", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ForbiddenResponse" + }, + "examples": { + "endpoint": { + "value": { + "detail": { + "cause": "User 6789 is not authorized to access this endpoint.", + "response": "User does not have permission to access this endpoint" + } + } + } + } + } + } + }, + "503": { + "description": "Service unavailable", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ServiceUnavailableResponse" + }, + "examples": { + "kubernetes api": { + "value": { + "detail": { + "cause": "Failed to connect to Kubernetes API: Service Unavailable (status 503)", + "response": "Unable to connect to Kubernetes API" + } + } + } + } + } + } + } + } + } + }, + "/metrics": { + "get": { + "tags": [ + "metrics" + ], + "summary": "Metrics Endpoint Handler", + "description": "Handle request to the /metrics endpoint.\n\nProcess GET requests to the /metrics endpoint, returning the\nlatest Prometheus metrics in plain text Prometheus format.\n\n### Parameters:\n- request: The incoming HTTP request (used by middleware).\n- auth: Authentication tuple from the auth dependency (used by middleware).\n\n### Returns:\n- PlainTextResponse: Response body containing the Prometheus metrics text\n and the Prometheus content type.", + "operationId": "metrics_endpoint_handler_metrics_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "examples": { + "missing header": { + "value": { + "detail": { + "cause": "No Authorization header found", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "missing token": { + "value": { + "detail": { + "cause": "No token found in Authorization header", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "expired token": { + "value": { + "detail": { + "cause": "Token has expired", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid signature": { + "value": { + "detail": { + "cause": "Invalid token signature", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid key": { + "value": { + "detail": { + "cause": "Token signed by unknown key", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "missing claim": { + "value": { + "detail": { + "cause": "Token missing claim: user_id", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid k8s token": { + "value": { + "detail": { + "cause": "Invalid or expired Kubernetes token", + "response": "Missing or invalid credentials provided by client" + } + } + }, + "invalid jwk token": { + "value": { + "detail": { + "cause": "Authentication key server returned invalid data", + "response": "Missing or invalid credentials provided by client" + } + } + } + } + }, + "text/plain": { + "schema": { + "$ref": "#/components/schemas/UnauthorizedResponse" + } + } + } + }, + "403": { + "description": "Permission denied", + "content": { + "application/json": { + "examples": { + "endpoint": { + "value": { + "detail": { + "cause": "User 6789 is not authorized to access this endpoint.", + "response": "User does not have permission to access this endpoint" + } + } + } + } + }, + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ForbiddenResponse" + } + } + } + }, + "500": { + "description": "Internal server error", + "content": { + "application/json": { + "examples": { + "configuration": { + "value": { + "detail": { + "cause": "Lightspeed Stack configuration has not been initialized.", + "response": "Configuration is not loaded" + } + } + } + } + }, + "text/plain": { + "schema": { + "$ref": "#/components/schemas/InternalServerErrorResponse" + } + } + } + }, + "503": { + "description": "Service unavailable", + "content": { + "application/json": { + "examples": { + "OGX": { + "value": { + "detail": { + "cause": "Connection error while trying to reach backend service.", + "response": "Unable to connect to OGX" + } + } + }, + "kubernetes api": { + "value": { + "detail": { + "cause": "Failed to connect to Kubernetes API: Service Unavailable (status 503)", + "response": "Unable to connect to Kubernetes API" + } + } + } + } + }, + "text/plain": { + "schema": { + "$ref": "#/components/schemas/ServiceUnavailableResponse" + } + } + } + } + } + } + }, + "/.well-known/agent-card.json": { + "get": { + "tags": [ + "a2a" + ], + "summary": "Get Agent Card", + "description": "Serve the A2A Agent Card at the well-known location.\n\nThis endpoint provides the agent card that describes Lightspeed's\ncapabilities according to the A2A protocol specification.\n\n### Parameters:\n- auth: Authentication tuple from the auth dependency (used by middleware).\n\n### Raises:\n- HTTPException: with status 500 and a detail object containing `response`\n and `cause` when service configuration is wrong or incomplete.\n- HTTPException: with status 503 and a detail object containing `response`\n and `cause` when unable to connect to OGX.\n\n### Returns:\n- AgentCard: The agent card describing this agent's capabilities.", + "operationId": "get_agent_card__well_known_agent_card_json_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AgentCard" + } + } + } + } + } + } + }, + "/.well-known/agent.json": { + "get": { + "tags": [ + "a2a" + ], + "summary": "Get Agent Card", + "description": "Serve the A2A Agent Card at the well-known location.\n\nThis endpoint provides the agent card that describes Lightspeed's\ncapabilities according to the A2A protocol specification.\n\n### Parameters:\n- auth: Authentication tuple from the auth dependency (used by middleware).\n\n### Raises:\n- HTTPException: with status 500 and a detail object containing `response`\n and `cause` when service configuration is wrong or incomplete.\n- HTTPException: with status 503 and a detail object containing `response`\n and `cause` when unable to connect to OGX.\n\n### Returns:\n- AgentCard: The agent card describing this agent's capabilities.", + "operationId": "get_agent_card__well_known_agent_json_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AgentCard" + } + } } } } @@ -10658,13 +11592,248 @@ "type": "null" } ], - "title": "Securityschemes" + "title": "Securityschemes" + }, + "signatures": { + "anyOf": [ + { + "items": { + "$ref": "#/components/schemas/AgentCardSignature" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "title": "Signatures" + }, + "skills": { + "items": { + "$ref": "#/components/schemas/AgentSkill" + }, + "type": "array", + "title": "Skills" + }, + "supportsAuthenticatedExtendedCard": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Supportsauthenticatedextendedcard" + }, + "url": { + "type": "string", + "title": "Url", + "examples": [ + "https://api.example.com/a2a/v1" + ] + }, + "version": { + "type": "string", + "title": "Version", + "examples": [ + "1.0.0" + ] + } + }, + "type": "object", + "required": [ + "capabilities", + "defaultInputModes", + "defaultOutputModes", + "description", + "name", + "skills", + "url", + "version" + ], + "title": "AgentCard", + "description": "The AgentCard is a self-describing manifest for an agent. It provides essential\nmetadata including the agent's identity, capabilities, skills, supported\ncommunication methods, and security requirements." + }, + "AgentCardSignature": { + "properties": { + "header": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Header" + }, + "protected": { + "type": "string", + "title": "Protected" + }, + "signature": { + "type": "string", + "title": "Signature" + } + }, + "type": "object", + "required": [ + "protected", + "signature" + ], + "title": "AgentCardSignature", + "description": "AgentCardSignature represents a JWS signature of an AgentCard.\nThis follows the JSON format of an RFC 7515 JSON Web Signature (JWS)." + }, + "AgentExtension": { + "properties": { + "description": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Description" + }, + "params": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Params" + }, + "required": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Required" + }, + "uri": { + "type": "string", + "title": "Uri" + } + }, + "type": "object", + "required": [ + "uri" + ], + "title": "AgentExtension", + "description": "A declaration of a protocol extension supported by an Agent." + }, + "AgentInterface": { + "properties": { + "transport": { + "type": "string", + "title": "Transport", + "examples": [ + "JSONRPC", + "GRPC", + "HTTP+JSON" + ] + }, + "url": { + "type": "string", + "title": "Url", + "examples": [ + "https://api.example.com/a2a/v1", + "https://grpc.example.com/a2a", + "https://rest.example.com/v1" + ] + } + }, + "type": "object", + "required": [ + "transport", + "url" + ], + "title": "AgentInterface", + "description": "Declares a combination of a target URL and a transport protocol for interacting with the agent.\nThis allows agents to expose the same functionality over multiple transport mechanisms." + }, + "AgentProvider": { + "properties": { + "organization": { + "type": "string", + "title": "Organization" + }, + "url": { + "type": "string", + "title": "Url" + } + }, + "type": "object", + "required": [ + "organization", + "url" + ], + "title": "AgentProvider", + "description": "Represents the service provider of an agent." + }, + "AgentSkill": { + "properties": { + "description": { + "type": "string", + "title": "Description" + }, + "examples": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "title": "Examples", + "examples": [ + [ + "I need a recipe for bread" + ] + ] + }, + "id": { + "type": "string", + "title": "Id" + }, + "inputModes": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "title": "Inputmodes" }, - "signatures": { + "name": { + "type": "string", + "title": "Name" + }, + "outputModes": { "anyOf": [ { "items": { - "$ref": "#/components/schemas/AgentCardSignature" + "type": "string" }, "type": "array" }, @@ -10672,334 +11841,468 @@ "type": "null" } ], - "title": "Signatures" - }, - "skills": { - "items": { - "$ref": "#/components/schemas/AgentSkill" - }, - "type": "array", - "title": "Skills" + "title": "Outputmodes" }, - "supportsAuthenticatedExtendedCard": { + "security": { "anyOf": [ { - "type": "boolean" + "items": { + "additionalProperties": { + "items": { + "type": "string" + }, + "type": "array" + }, + "type": "object" + }, + "type": "array" }, { "type": "null" } ], - "title": "Supportsauthenticatedextendedcard" - }, - "url": { - "type": "string", - "title": "Url", + "title": "Security", "examples": [ - "https://api.example.com/a2a/v1" + [ + { + "google": [ + "oidc" + ] + } + ] ] }, - "version": { - "type": "string", - "title": "Version", + "tags": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Tags", "examples": [ - "1.0.0" + [ + "cooking", + "customer support", + "billing" + ] ] } }, "type": "object", "required": [ - "capabilities", - "defaultInputModes", - "defaultOutputModes", "description", + "id", "name", - "skills", - "url", - "version" + "tags" ], - "title": "AgentCard", - "description": "The AgentCard is a self-describing manifest for an agent. It provides essential\nmetadata including the agent's identity, capabilities, skills, supported\ncommunication methods, and security requirements." + "title": "AgentSkill", + "description": "Represents a distinct capability or function that an agent can perform." }, - "AgentCardSignature": { + "AgentStepPersistenceNoopConfiguration": { "properties": { - "header": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Header" - }, - "protected": { + "type": { "type": "string", - "title": "Protected" - }, - "signature": { + "const": "noop", + "title": "Type", + "description": "Disable persistence of agent steps.", + "default": "noop" + } + }, + "additionalProperties": false, + "type": "object", + "title": "AgentStepPersistenceNoopConfiguration", + "description": "Agent step persistence disabled (no harness store)." + }, + "AgentStepPersistenceSqliteConfiguration": { + "properties": { + "type": { "type": "string", - "title": "Signature" + "const": "sqlite", + "title": "Type", + "description": "Persist agent steps in a SQLite database.", + "default": "sqlite" + }, + "sqlite": { + "$ref": "#/components/schemas/SQLiteDatabaseConfiguration", + "title": "SQLite database", + "description": "SQLite file for harness step persistence." } }, + "additionalProperties": false, "type": "object", "required": [ - "protected", - "signature" + "sqlite" ], - "title": "AgentCardSignature", - "description": "AgentCardSignature represents a JWS signature of an AgentCard.\nThis follows the JSON format of an RFC 7515 JSON Web Signature (JWS)." + "title": "AgentStepPersistenceSqliteConfiguration", + "description": "SQLite-backed harness step store." }, - "AgentExtension": { + "AgentTurn": { "properties": { - "description": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Description" + "id": { + "type": "string", + "title": "Id", + "description": "Run identity (run_id / response id)" }, - "params": { - "anyOf": [ - { - "additionalProperties": true, - "type": "object" - }, - { - "type": "null" - } + "status": { + "type": "string", + "enum": [ + "completed", + "interrupted", + "failed", + "awaiting_input" ], - "title": "Params" + "title": "Status", + "description": "Run lifecycle status" }, - "required": { + "agent": { "anyOf": [ { - "type": "boolean" + "type": "string" }, { "type": "null" } ], - "title": "Required" + "title": "Agent", + "description": "Optional agent identifier; reserved for future use" }, - "uri": { + "provider": { "type": "string", - "title": "Uri" - } - }, - "type": "object", - "required": [ - "uri" - ], - "title": "AgentExtension", - "description": "A declaration of a protocol extension supported by an Agent." - }, - "AgentInterface": { - "properties": { - "transport": { + "title": "Provider", + "description": "Inference provider used for the run" + }, + "model": { "type": "string", - "title": "Transport", + "title": "Model", + "description": "Inference model used for the run" + }, + "started_at": { + "type": "string", + "format": "date-time", + "title": "Started At", + "description": "UTC timestamp when the run started", "examples": [ - "JSONRPC", - "GRPC", - "HTTP+JSON" + "2024-01-01T00:01:00Z" ] }, - "url": { + "completed_at": { "type": "string", - "title": "Url", + "format": "date-time", + "title": "Completed At", + "description": "UTC timestamp when the run completed or paused", "examples": [ - "https://api.example.com/a2a/v1", - "https://grpc.example.com/a2a", - "https://rest.example.com/v1" + "2024-01-01T00:01:05Z" ] + }, + "context_status": { + "type": "string", + "enum": [ + "full", + "compacted" + ], + "title": "Context Status", + "description": "Whether agent history for this run was full or compacted" + }, + "usage": { + "$ref": "#/components/schemas/TurnUsage", + "description": "Aggregated token usage for the run" + }, + "referenced_documents": { + "items": { + "$ref": "#/components/schemas/ReferencedDocument" + }, + "type": "array", + "title": "Referenced Documents", + "description": "Deduplicated citations for the turn" + }, + "input": { + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/MessageTurnItem" + }, + { + "$ref": "#/components/schemas/ToolCallTurnItem" + }, + { + "$ref": "#/components/schemas/ToolResultTurnItem" + }, + { + "$ref": "#/components/schemas/SourcesTurnItem" + }, + { + "$ref": "#/components/schemas/ReasoningTurnItem" + }, + { + "$ref": "#/components/schemas/ApprovalRequestTurnItem" + }, + { + "$ref": "#/components/schemas/ApprovalResultTurnItem" + } + ], + "discriminator": { + "propertyName": "kind", + "mapping": { + "approval_request": "#/components/schemas/ApprovalRequestTurnItem", + "approval_result": "#/components/schemas/ApprovalResultTurnItem", + "message": "#/components/schemas/MessageTurnItem", + "reasoning": "#/components/schemas/ReasoningTurnItem", + "sources": "#/components/schemas/SourcesTurnItem", + "tool_call": "#/components/schemas/ToolCallTurnItem", + "tool_result": "#/components/schemas/ToolResultTurnItem" + } + } + }, + "type": "array", + "title": "Input", + "description": "Ordered items that started the run" + }, + "output": { + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/MessageTurnItem" + }, + { + "$ref": "#/components/schemas/ToolCallTurnItem" + }, + { + "$ref": "#/components/schemas/ToolResultTurnItem" + }, + { + "$ref": "#/components/schemas/SourcesTurnItem" + }, + { + "$ref": "#/components/schemas/ReasoningTurnItem" + }, + { + "$ref": "#/components/schemas/ApprovalRequestTurnItem" + }, + { + "$ref": "#/components/schemas/ApprovalResultTurnItem" + } + ], + "discriminator": { + "propertyName": "kind", + "mapping": { + "approval_request": "#/components/schemas/ApprovalRequestTurnItem", + "approval_result": "#/components/schemas/ApprovalResultTurnItem", + "message": "#/components/schemas/MessageTurnItem", + "reasoning": "#/components/schemas/ReasoningTurnItem", + "sources": "#/components/schemas/SourcesTurnItem", + "tool_call": "#/components/schemas/ToolCallTurnItem", + "tool_result": "#/components/schemas/ToolResultTurnItem" + } + } + }, + "type": "array", + "title": "Output", + "description": "Ordered items the run produced" } }, "type": "object", "required": [ - "transport", - "url" + "id", + "status", + "provider", + "model", + "started_at", + "completed_at", + "context_status" ], - "title": "AgentInterface", - "description": "Declares a combination of a target URL and a transport protocol for interacting with the agent.\nThis allows agents to expose the same functionality over multiple transport mechanisms." + "title": "AgentTurn", + "description": "One agent run in the public conversation timeline.\n\nA turn is one PAI Agent.run (same identity as Responses response.id when\nthat path created the run). The timeline order within a turn is input\nfollowed by output." }, - "AgentProvider": { + "AgenticConversationGetResponse": { "properties": { - "organization": { + "conversation_id": { "type": "string", - "title": "Organization" + "title": "Conversation Id", + "description": "Conversation ID (UUID)", + "examples": [ + "c5260aec-4d82-4370-9fdf-05cf908b3f16" + ] }, - "url": { - "type": "string", - "title": "Url" - } - }, - "type": "object", - "required": [ - "organization", - "url" - ], - "title": "AgentProvider", - "description": "Represents the service provider of an agent." - }, - "AgentSkill": { - "properties": { - "description": { + "created_at": { "type": "string", - "title": "Description" + "format": "date-time", + "title": "Created At", + "description": "When the conversation was created (UTC)", + "examples": [ + "2024-01-01T01:00:00Z" + ] }, - "examples": { + "last_turn_at": { "anyOf": [ { - "items": { - "type": "string" - }, - "type": "array" + "type": "string", + "format": "date-time" }, { "type": "null" } ], - "title": "Examples", + "title": "Last Turn At", + "description": "When the most recent agent run completed or paused (UTC)", "examples": [ - [ - "I need a recipe for bread" - ] + "2024-01-01T01:05:00Z" ] }, - "id": { - "type": "string", - "title": "Id" + "turn_count": { + "type": "integer", + "minimum": 0.0, + "title": "Turn Count", + "description": "Number of agent runs in the conversation", + "default": 0, + "examples": [ + 3 + ] }, - "inputModes": { + "last_used_model": { "anyOf": [ { - "items": { - "type": "string" - }, - "type": "array" + "type": "string" }, { "type": "null" } ], - "title": "Inputmodes" - }, - "name": { - "type": "string", - "title": "Name" + "title": "Last Used Model", + "description": "Identification of the last model used", + "examples": [ + "gpt-5.6-luna" + ] }, - "outputModes": { + "last_used_provider": { "anyOf": [ { - "items": { - "type": "string" - }, - "type": "array" + "type": "string" }, { "type": "null" } ], - "title": "Outputmodes" + "title": "Last Used Provider", + "description": "Identification of the last provider used", + "examples": [ + "openai" + ] }, - "security": { + "topic_summary": { "anyOf": [ { - "items": { - "additionalProperties": { - "items": { - "type": "string" - }, - "type": "array" - }, - "type": "object" - }, - "type": "array" + "type": "string" }, { "type": "null" } ], - "title": "Security", + "title": "Topic Summary", + "description": "Topic summary for the conversation", "examples": [ - [ - { - "google": [ - "oidc" - ] - } - ] + "OpenShift deployment strategies" ] }, - "tags": { + "chat_history": { "items": { - "type": "string" + "$ref": "#/components/schemas/AgentTurn" }, "type": "array", - "title": "Tags", - "examples": [ - [ - "cooking", - "customer support", - "billing" - ] - ] + "title": "Chat History", + "description": "Ordered agent runs for the conversation" } }, "type": "object", "required": [ - "description", - "id", - "name", - "tags" + "conversation_id", + "created_at" ], - "title": "AgentSkill", - "description": "Represents a distinct capability or function that an agent can perform." - }, - "AgentStepPersistenceNoopConfiguration": { - "properties": { - "type": { - "type": "string", - "const": "noop", - "title": "Type", - "description": "Disable persistence of agent steps.", - "default": "noop" + "title": "AgenticConversationGetResponse", + "description": "Response for one agentic conversation.\n\nAttributes:\n conversation_id: Conversation identifier.\n created_at: When the conversation was created.\n last_turn_at: When the most recent agent run completed or paused.\n turn_count: Number of agent runs in the conversation.\n last_used_model: Model used on the last agent run.\n last_used_provider: Provider used on the last agent run.\n topic_summary: Topic summary when available.\n chat_history: Ordered agent turns shown to the client.", + "examples": [ + { + "chat_history": [ + { + "completed_at": "2024-01-01T00:01:05Z", + "context_status": "full", + "id": "resp_1", + "input": [ + { + "content": [ + { + "text": "Hello", + "type": "text" + } + ], + "id": "msg_user_1", + "kind": "message", + "role": "user" + } + ], + "model": "gpt-5.6-luna", + "output": [ + { + "content": [ + { + "text": "Hi there!", + "type": "text" + } + ], + "id": "msg_assistant_1", + "kind": "message", + "role": "assistant" + } + ], + "provider": "openai", + "referenced_documents": [], + "started_at": "2024-01-01T00:01:00Z", + "status": "completed", + "usage": { + "input_tokens": 4, + "output_tokens": 6 + } + } + ], + "conversation_id": "123e4567-e89b-12d3-a456-426614174000", + "created_at": "2024-01-01T00:00:00Z", + "last_turn_at": "2024-01-01T00:01:05Z", + "last_used_model": "gpt-5.6-luna", + "last_used_provider": "openai", + "topic_summary": "OpenShift deployment strategies", + "turn_count": 1 } - }, - "additionalProperties": false, - "type": "object", - "title": "AgentStepPersistenceNoopConfiguration", - "description": "Agent step persistence disabled (no harness store)." + ] }, - "AgentStepPersistenceSqliteConfiguration": { + "AgenticConversationListResponse": { "properties": { - "type": { - "type": "string", - "const": "sqlite", - "title": "Type", - "description": "Persist agent steps in a SQLite database.", - "default": "sqlite" - }, - "sqlite": { - "$ref": "#/components/schemas/SQLiteDatabaseConfiguration", - "title": "SQLite database", - "description": "SQLite file for harness step persistence." + "conversations": { + "items": { + "$ref": "#/components/schemas/ConversationMetadata" + }, + "type": "array", + "title": "Conversations" } }, - "additionalProperties": false, "type": "object", "required": [ - "sqlite" + "conversations" ], - "title": "AgentStepPersistenceSqliteConfiguration", - "description": "SQLite-backed harness step store." + "title": "AgenticConversationListResponse", + "description": "Response listing agentic conversations for the user.\n\nAttributes:\n conversations: Conversation metadata only; turn history is omitted.", + "examples": [ + { + "conversations": [ + { + "conversation_id": "123e4567-e89b-12d3-a456-426614174000", + "created_at": "2024-01-01T00:00:00Z", + "last_turn_at": "2024-01-01T00:01:05Z", + "last_used_model": "gpt-5.6-luna", + "last_used_provider": "openai", + "topic_summary": "OpenShift deployment strategies", + "turn_count": 1 + } + ] + } + ] }, "AllowedModel": { "properties": { @@ -11097,36 +12400,132 @@ "type": "null" } ], - "title": "Never" + "title": "Never" + } + }, + "type": "object", + "title": "ApprovalFilter", + "description": "Filter configuration for MCP tool approval requirements.\n\n:param always: (Optional) List of tool names that always require approval\n:param never: (Optional) List of tool names that never require approval" + }, + "ApprovalFilter-Output": { + "properties": { + "always": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Always require approval", + "description": "List of tool names that always require human approval" + }, + "never": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Never require approval", + "description": "List of tool names that never require approval" + } + }, + "additionalProperties": false, + "type": "object", + "title": "ApprovalFilter", + "description": "Granular approval control for specific MCP tools.\n\nAttributes:\n always: Tool names that always require human approval before execution.\n never: Tool names that never require approval (pre-approved)." + }, + "ApprovalRequestTurnItem": { + "properties": { + "id": { + "type": "string", + "title": "Id", + "description": "Stable identifier for this turn item" + }, + "kind": { + "type": "string", + "const": "approval_request", + "title": "Kind", + "default": "approval_request" + }, + "call_id": { + "type": "string", + "title": "Call Id", + "description": "Related tool call identifier" + }, + "name": { + "type": "string", + "title": "Name", + "description": "Tool name for the invocation pending approval" + }, + "arguments": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Arguments", + "description": "Arguments for the invocation pending approval" + }, + "toolset": { + "$ref": "#/components/schemas/ToolsetInfo", + "description": "Tool family classification for the pending invocation" } }, "type": "object", - "title": "ApprovalFilter", - "description": "Filter configuration for MCP tool approval requirements.\n\n:param always: (Optional) List of tool names that always require approval\n:param never: (Optional) List of tool names that never require approval" + "required": [ + "id", + "call_id", + "name", + "toolset" + ], + "title": "ApprovalRequestTurnItem", + "description": "Human-in-the-loop approval request (typically in output)." }, - "ApprovalFilter-Output": { + "ApprovalResultTurnItem": { "properties": { - "always": { - "items": { - "type": "string" - }, - "type": "array", - "title": "Always require approval", - "description": "List of tool names that always require human approval" + "id": { + "type": "string", + "title": "Id", + "description": "Stable identifier for this turn item" }, - "never": { - "items": { - "type": "string" - }, - "type": "array", - "title": "Never require approval", - "description": "List of tool names that never require approval" + "kind": { + "type": "string", + "const": "approval_result", + "title": "Kind", + "default": "approval_result" + }, + "call_id": { + "type": "string", + "title": "Call Id", + "description": "Related tool call identifier" + }, + "approved": { + "type": "boolean", + "title": "Approved", + "description": "Whether the action was approved" + }, + "reason": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Reason", + "description": "Optional explanation for the decision" } }, - "additionalProperties": false, "type": "object", - "title": "ApprovalFilter", - "description": "Granular approval control for specific MCP tools.\n\nAttributes:\n always: Tool names that always require human approval before execution.\n never: Tool names that never require approval (pre-approved)." + "required": [ + "id", + "call_id", + "approved" + ], + "title": "ApprovalResultTurnItem", + "description": "Approval decision when resuming a deferred run (typically in input)." }, "ApprovalsConfiguration": { "properties": { @@ -12761,6 +14160,105 @@ "title": "ConversationListItemV2", "description": "v2 conversations list item: envelope metadata plus cache activity timestamp." }, + "ConversationMetadata": { + "properties": { + "conversation_id": { + "type": "string", + "title": "Conversation Id", + "description": "Conversation ID (UUID)", + "examples": [ + "c5260aec-4d82-4370-9fdf-05cf908b3f16" + ] + }, + "created_at": { + "type": "string", + "format": "date-time", + "title": "Created At", + "description": "When the conversation was created (UTC)", + "examples": [ + "2024-01-01T01:00:00Z" + ] + }, + "last_turn_at": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "Last Turn At", + "description": "When the most recent agent run completed or paused (UTC)", + "examples": [ + "2024-01-01T01:05:00Z" + ] + }, + "turn_count": { + "type": "integer", + "minimum": 0.0, + "title": "Turn Count", + "description": "Number of agent runs in the conversation", + "default": 0, + "examples": [ + 3 + ] + }, + "last_used_model": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Last Used Model", + "description": "Identification of the last model used", + "examples": [ + "gpt-5.6-luna" + ] + }, + "last_used_provider": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Last Used Provider", + "description": "Identification of the last provider used", + "examples": [ + "openai" + ] + }, + "topic_summary": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Topic Summary", + "description": "Topic summary for the conversation", + "examples": [ + "OpenShift deployment strategies" + ] + } + }, + "type": "object", + "required": [ + "conversation_id", + "created_at" + ], + "title": "ConversationMetadata", + "description": "Shared metadata for get and list conversation responses." + }, "ConversationResponse": { "properties": { "conversation_id": { @@ -12944,10 +14442,8 @@ "message": { "type": "string", "title": "Message", - "description": "A message about the update result", - "examples": [ - "Topic summary updated successfully" - ] + "description": "Outcome message for the topic summary update.", + "readOnly": true } }, "type": "object", @@ -12957,7 +14453,7 @@ "message" ], "title": "ConversationUpdateResponse", - "description": "Model representing a response for updating a conversation topic summary.\n\nAttributes:\n conversation_id: The conversation ID (UUID) that was updated.\n success: Whether the update was successful.\n message: A message about the update result.", + "description": "Model representing a response for updating a conversation topic summary.\n\nAttributes:\n conversation_id: The conversation ID (UUID) that was updated.\n success: Whether the update was successful.\n message: Human-readable outcome derived from ``success``.", "examples": [ { "conversation_id": "123e4567-e89b-12d3-a456-426614174000", @@ -13456,6 +14952,43 @@ } ] }, + "FileContentPart": { + "properties": { + "type": { + "type": "string", + "const": "file", + "title": "Type", + "default": "file" + }, + "file_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "File Id", + "description": "Uploaded file identifier" + }, + "filename": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Filename", + "description": "Original filename when available" + } + }, + "type": "object", + "title": "FileContentPart", + "description": "File reference within a multimodal message." + }, "FileResponse": { "properties": { "id": { @@ -13828,6 +15361,57 @@ "title": "HealthStatus", "description": "Health status enum for provider and service health checks.\n\nThis enum serves two purposes:\n\n1. Provider-level health (returned by OGX providers):\n - OK: Provider is healthy and operational\n - ERROR: Provider is unhealthy or failed health check\n - NOT_IMPLEMENTED: Provider does not implement health checks\n - UNKNOWN: Fallback when provider status cannot be determined\n\n2. Service-level health (overall LCORE status):\n - HEALTHY: All systems operational, LLS connected, all providers healthy\n - UNHEALTHY: Service connected but one or more providers are unhealthy" }, + "ImageContentPart": { + "properties": { + "type": { + "type": "string", + "const": "image", + "title": "Type", + "default": "image" + }, + "image_url": { + "anyOf": [ + { + "type": "string", + "minLength": 1, + "format": "uri" + }, + { + "type": "null" + } + ], + "title": "Image Url", + "description": "URL of the image, including data URIs for inline bytes" + }, + "file_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "File Id", + "description": "Uploaded file identifier when the image is stored by LCORE" + }, + "media_type": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Media Type", + "description": "MIME type of the image when known, for example image/png" + } + }, + "type": "object", + "title": "ImageContentPart", + "description": "Image reference for display (not raw bytes).\n\nClients render a URL (http or data URI) and/or an uploaded file id.\nInference-only fields such as vision detail are not stored in display history." + }, "ImplicitOAuthFlow": { "properties": { "authorizationUrl": { @@ -14207,6 +15791,13 @@ }, "label": "database" }, + { + "detail": { + "cause": "Failed to list conversations due to a database error.", + "response": "Database query failed" + }, + "label": "database operation" + }, { "detail": { "cause": "ClusterVersion 'version' resource not found in OpenShift cluster", @@ -14778,29 +16369,89 @@ "developer" ] }, - "referenced_documents": { - "anyOf": [ - { - "items": { - "$ref": "#/components/schemas/ReferencedDocument" - }, - "type": "array" - }, - { - "type": "null" - } + "referenced_documents": { + "anyOf": [ + { + "items": { + "$ref": "#/components/schemas/ReferencedDocument" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "title": "Referenced Documents", + "description": "List of documents referenced in the response (assistant messages only)" + } + }, + "type": "object", + "required": [ + "content", + "type" + ], + "title": "Message", + "description": "Model representing a message in a conversation turn.\n\nAttributes:\n content: The message content.\n type: The type of message.\n referenced_documents: Optional list of documents referenced in an assistant response." + }, + "MessageContent": { + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/TextContentPart" + }, + { + "$ref": "#/components/schemas/ImageContentPart" + }, + { + "$ref": "#/components/schemas/FileContentPart" + } + ], + "discriminator": { + "propertyName": "type", + "mapping": { + "file": "#/components/schemas/FileContentPart", + "image": "#/components/schemas/ImageContentPart", + "text": "#/components/schemas/TextContentPart" + } + } + }, + "type": "array" + }, + "MessageTurnItem": { + "properties": { + "id": { + "type": "string", + "title": "Id", + "description": "Stable identifier for this turn item" + }, + "kind": { + "type": "string", + "const": "message", + "title": "Kind", + "default": "message" + }, + "role": { + "type": "string", + "enum": [ + "user", + "assistant" ], - "title": "Referenced Documents", - "description": "List of documents referenced in the response (assistant messages only)" + "title": "Role", + "description": "Message author" + }, + "content": { + "$ref": "#/components/schemas/MessageContent", + "description": "Ordered multimodal message parts" } }, "type": "object", "required": [ - "content", - "type" + "id", + "role", + "content" ], - "title": "Message", - "description": "Model representing a message in a conversation turn.\n\nAttributes:\n content: The message content.\n type: The type of message.\n referenced_documents: Optional list of documents referenced in an assistant response." + "title": "MessageTurnItem", + "description": "User or assistant multimodal message." }, "ModelContextProtocolServer": { "properties": { @@ -18933,6 +20584,33 @@ } ] }, + "ReasoningTurnItem": { + "properties": { + "id": { + "type": "string", + "title": "Id", + "description": "Stable identifier for this turn item" + }, + "kind": { + "type": "string", + "const": "reasoning", + "title": "Kind", + "default": "reasoning" + }, + "content": { + "type": "string", + "title": "Content", + "description": "Reasoning text" + } + }, + "type": "object", + "required": [ + "id", + "content" + ], + "title": "ReasoningTurnItem", + "description": "Optional reasoning content exposed for the run." + }, "RedactionConfig": { "properties": { "rules": { @@ -21231,6 +22909,97 @@ "title": "SolrVectorSearchRequest", "description": "LCORE Solr inline RAG options for vector_io.query (mode and provider filters).\n\nAttributes:\n mode: Solr vector_io search mode. When omitted, the configured OKP default is used.\n filters: Solr provider filter payload passed through as params['solr'].\n\nLegacy clients may send a plain JSON object with filter keys only;\nthat object is accepted as filters with mode unset (server default applies)." }, + "SourceChunk": { + "properties": { + "content": { + "type": "string", + "title": "Content", + "description": "Chunk text" + }, + "source": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Source", + "description": "Knowledge source or index name" + }, + "score": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Score", + "description": "Relevance score" + }, + "attributes": { + "anyOf": [ + { + "additionalProperties": true, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Attributes", + "description": "Document metadata from the provider" + } + }, + "type": "object", + "required": [ + "content" + ], + "title": "SourceChunk", + "description": "Retrieval chunk attached to a sources turn item." + }, + "SourcesTurnItem": { + "properties": { + "id": { + "type": "string", + "title": "Id", + "description": "Stable identifier for this turn item" + }, + "kind": { + "type": "string", + "const": "sources", + "title": "Kind", + "default": "sources" + }, + "origin": { + "type": "string", + "enum": [ + "auto", + "tool" + ], + "title": "Origin", + "description": "Whether evidence came from automatic RAG or a tool" + }, + "chunks": { + "items": { + "$ref": "#/components/schemas/SourceChunk" + }, + "type": "array", + "title": "Chunks", + "description": "Retrieved chunks for this item" + } + }, + "type": "object", + "required": [ + "id", + "origin" + ], + "title": "SourcesTurnItem", + "description": "Retrieval evidence for the turn (automatic RAG or tool-backed)." + }, "SplunkConfiguration": { "properties": { "enabled": { @@ -21453,6 +23222,27 @@ "title": "TLSConfiguration", "description": "TLS configuration.\n\nTransport Layer Security (TLS) is a cryptographic protocol designed to\nprovide communications security over a computer network, such as the\nInternet. The protocol is widely used in applications such as email,\ninstant messaging, and voice over IP, but its use in securing HTTPS remains\nthe most publicly visible.\n\nUseful resources:\n\n - [FastAPI HTTPS Deployment](https://fastapi.tiangolo.com/deployment/https/)\n - [Transport Layer Security Overview](https://en.wikipedia.org/wiki/Transport_Layer_Security)\n - [What is TLS](https://www.ssltrust.eu/learning/ssl/transport-layer-security-tls)" }, + "TextContentPart": { + "properties": { + "type": { + "type": "string", + "const": "text", + "title": "Type", + "default": "text" + }, + "text": { + "type": "string", + "title": "Text", + "description": "Message text" + } + }, + "type": "object", + "required": [ + "text" + ], + "title": "TextContentPart", + "description": "Text segment within a multimodal message." + }, "TooManyConcurrentRequestsResponse": { "properties": { "status_code": { @@ -21522,6 +23312,65 @@ "title": "ToolCallSummary", "description": "Model representing a tool call made during response generation (for tool_calls list)." }, + "ToolCallTurnItem": { + "properties": { + "id": { + "type": "string", + "title": "Id", + "description": "Stable identifier for this turn item" + }, + "kind": { + "type": "string", + "const": "tool_call", + "title": "Kind", + "default": "tool_call" + }, + "call_id": { + "type": "string", + "title": "Call Id", + "description": "Tool call identifier" + }, + "name": { + "type": "string", + "title": "Name", + "description": "Tool name" + }, + "arguments": { + "additionalProperties": true, + "type": "object", + "title": "Arguments", + "description": "Arguments passed to the tool" + }, + "toolset": { + "$ref": "#/components/schemas/ToolsetInfo", + "description": "Tool family classification for this call" + } + }, + "type": "object", + "required": [ + "id", + "call_id", + "name", + "toolset" + ], + "title": "ToolCallTurnItem", + "description": "Tool invocation produced during a run." + }, + "ToolResultBody": { + "anyOf": [ + { + "type": "string" + }, + { + "additionalProperties": true, + "type": "object" + }, + { + "items": {}, + "type": "array" + } + ] + }, "ToolResultSummary": { "properties": { "id": { @@ -21561,6 +23410,67 @@ "title": "ToolResultSummary", "description": "Model representing a result from a tool call (for tool_results list)." }, + "ToolResultTurnItem": { + "properties": { + "id": { + "type": "string", + "title": "Id", + "description": "Stable identifier for this turn item" + }, + "kind": { + "type": "string", + "const": "tool_result", + "title": "Kind", + "default": "tool_result" + }, + "call_id": { + "type": "string", + "title": "Call Id", + "description": "Matches the corresponding tool_call call_id" + }, + "name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Name", + "description": "Tool name when useful without the paired tool_call item" + }, + "status": { + "type": "string", + "enum": [ + "success", + "failed", + "denied", + "interrupted" + ], + "title": "Status", + "description": "success: normal completion; failed: execution error; denied: blocked or not recorded (guardrail, etc.); interrupted: run stopped before tool finished" + }, + "content": { + "$ref": "#/components/schemas/ToolResultBody", + "description": "Tool outcome: UTF-8 text or structured JSON (object or array)" + }, + "toolset": { + "$ref": "#/components/schemas/ToolsetInfo", + "description": "Tool family classification for this result" + } + }, + "type": "object", + "required": [ + "id", + "call_id", + "status", + "content", + "toolset" + ], + "title": "ToolResultTurnItem", + "description": "Outcome of a tool call." + }, "ToolsResponse": { "properties": { "tools": { @@ -21601,6 +23511,42 @@ } ] }, + "ToolsetInfo": { + "properties": { + "type": { + "type": "string", + "enum": [ + "function", + "mcp", + "file_search", + "skills" + ], + "title": "Type", + "description": "Tool family: function, mcp, file_search, or skills" + }, + "label": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Label", + "description": "Human-readable toolset label when applicable", + "examples": [ + "filesystem" + ] + } + }, + "type": "object", + "required": [ + "type" + ], + "title": "ToolsetInfo", + "description": "Classifies which tool family a call or result belongs to for display." + }, "TrustedProxyConfiguration": { "properties": { "user_header": { @@ -21652,6 +23598,27 @@ "title": "TrustedProxyServiceAccount", "description": "A Kubernetes ServiceAccount identity for trusted-proxy allowlist." }, + "TurnUsage": { + "properties": { + "input_tokens": { + "type": "integer", + "minimum": 0.0, + "title": "Input Tokens", + "description": "Tokens sent to the model during the run", + "default": 0 + }, + "output_tokens": { + "type": "integer", + "minimum": 0.0, + "title": "Output Tokens", + "description": "Tokens received from the model during the run", + "default": 0 + } + }, + "type": "object", + "title": "TurnUsage", + "description": "Aggregated token usage for one agent run." + }, "UnauthorizedResponse": { "properties": { "status_code": { @@ -23164,6 +25131,10 @@ "name": "conversations_v2", "description": "Conversations API v2." }, + { + "name": "conversations_v3", + "description": "Conversations API v3." + }, { "name": "feedback", "description": "User feedback." diff --git a/docs/models/error_responses.json b/docs/models/error_responses.json index 80675365cc..d3a5565e3f 100644 --- a/docs/models/error_responses.json +++ b/docs/models/error_responses.json @@ -306,6 +306,13 @@ }, "label": "database" }, + { + "detail": { + "cause": "Failed to list conversations due to a database error.", + "response": "Database query failed" + }, + "label": "database operation" + }, { "detail": { "cause": "ClusterVersion 'version' resource not found in OpenShift cluster", @@ -363,6 +370,13 @@ }, "label": "conversation" }, + { + "detail": { + "cause": "Response with ID resp_abc123 does not exist", + "response": "Response not found" + }, + "label": "response" + }, { "detail": { "cause": "Provider with ID openai does not exist", @@ -726,4 +740,4 @@ } }, "paths": {} -} \ No newline at end of file +} diff --git a/src/app/README.md b/src/app/README.md index db3484aa6b..e5a7301974 100644 --- a/src/app/README.md +++ b/src/app/README.md @@ -8,6 +8,14 @@ REST API service based on FastAPI. Database engine management. +## [endpoints/](endpoints/) + +Handlers for REST API endpoints. + +## [exceptions/](exceptions/) + +Centralized domain-exception-to-HTTP translation (handlers and per-domain mappings). + ## [main.py](main.py) Definition of FastAPI based web service. diff --git a/src/app/endpoints/README.md b/src/app/endpoints/README.md index 2754311de4..7a51503315 100644 --- a/src/app/endpoints/README.md +++ b/src/app/endpoints/README.md @@ -28,6 +28,10 @@ Handler for REST API calls to manage conversation history using Conversations AP Handler for REST API calls to manage conversation history. +## [conversations_v3.py](conversations_v3.py) + +Handler for REST API calls to manage agentic display-history conversations. + ## [feedback.py](feedback.py) Handler for REST API endpoint for user feedback. diff --git a/src/app/endpoints/conversations_v2.py b/src/app/endpoints/conversations_v2.py index 22680daca0..1f626c1988 100644 --- a/src/app/endpoints/conversations_v2.py +++ b/src/app/endpoints/conversations_v2.py @@ -268,7 +268,6 @@ async def update_conversation_endpoint_handler( return ConversationUpdateResponse( conversation_id=conversation_id, success=True, - message="Topic summary updated successfully", ) diff --git a/src/app/endpoints/conversations_v3.py b/src/app/endpoints/conversations_v3.py new file mode 100644 index 0000000000..7f71cefe15 --- /dev/null +++ b/src/app/endpoints/conversations_v3.py @@ -0,0 +1,275 @@ +"""Handler for REST API calls to manage agentic display-history conversations.""" + +from typing import Any + +from fastapi import APIRouter, Depends, Request +from fastapi.concurrency import run_in_threadpool +from opentelemetry import trace + +from authentication import get_auth_dependency +from authorization.middleware import authorize +from configuration import configuration +from conversations.display_history.ids import validate_conversation_id +from conversations.display_history.persistence.facade.conversation import ( + delete_conversation, + get_conversation, + list_conversations, + update_conversation_topic, +) +from log import get_logger +from models.api.requests import ConversationUpdateRequest +from models.api.responses.constants import UNAUTHORIZED_OPENAPI_EXAMPLES +from models.api.responses.error import ( + BadRequestResponse, + ForbiddenResponse, + InternalServerErrorResponse, + NotFoundResponse, + ServiceUnavailableResponse, + UnauthorizedResponse, +) +from models.api.responses.successful import ( + AgenticConversationGetResponse, + AgenticConversationListResponse, + ConversationDeleteResponse, + ConversationUpdateResponse, +) +from models.config import Action +from utils.endpoints import check_configuration_loaded +from utils.types import Responses + +logger = get_logger(__name__) +tracer = trace.get_tracer(__name__) +router = APIRouter(tags=["conversations_v3"]) + + +conversation_get_responses: Responses = { + 200: AgenticConversationGetResponse.openapi_response(), + 400: BadRequestResponse.openapi_response(examples=["conversation_id"]), + 401: UnauthorizedResponse.openapi_response(examples=UNAUTHORIZED_OPENAPI_EXAMPLES), + 403: ForbiddenResponse.openapi_response(examples=["conversation read", "endpoint"]), + 404: NotFoundResponse.openapi_response(examples=["conversation"]), + 500: InternalServerErrorResponse.openapi_response( + examples=["database operation", "configuration"] + ), + 503: ServiceUnavailableResponse.openapi_response(examples=["kubernetes api"]), +} + +conversation_delete_responses: Responses = { + 200: ConversationDeleteResponse.openapi_response(), + 400: BadRequestResponse.openapi_response(examples=["conversation_id"]), + 401: UnauthorizedResponse.openapi_response(examples=UNAUTHORIZED_OPENAPI_EXAMPLES), + 403: ForbiddenResponse.openapi_response( + examples=["conversation delete", "endpoint"] + ), + 500: InternalServerErrorResponse.openapi_response( + examples=["database operation", "configuration"] + ), + 503: ServiceUnavailableResponse.openapi_response(examples=["kubernetes api"]), +} + +conversations_list_responses: Responses = { + 200: AgenticConversationListResponse.openapi_response(), + 401: UnauthorizedResponse.openapi_response(examples=UNAUTHORIZED_OPENAPI_EXAMPLES), + 403: ForbiddenResponse.openapi_response(examples=["endpoint"]), + 500: InternalServerErrorResponse.openapi_response( + examples=["database operation", "configuration"] + ), + 503: ServiceUnavailableResponse.openapi_response(examples=["kubernetes api"]), +} + +conversation_update_responses: Responses = { + 200: ConversationUpdateResponse.openapi_response(), + 400: BadRequestResponse.openapi_response(examples=["conversation_id"]), + 401: UnauthorizedResponse.openapi_response(examples=UNAUTHORIZED_OPENAPI_EXAMPLES), + 403: ForbiddenResponse.openapi_response(examples=["endpoint"]), + 404: NotFoundResponse.openapi_response(examples=["conversation"]), + 500: InternalServerErrorResponse.openapi_response( + examples=["database operation", "configuration"] + ), + 503: ServiceUnavailableResponse.openapi_response(examples=["kubernetes api"]), +} + + +@router.get("/conversations", responses=conversations_list_responses) +@authorize(Action.LIST_CONVERSATIONS) +async def get_conversations_list_endpoint_handler( + request: Request, + auth: Any = Depends(get_auth_dependency()), +) -> AgenticConversationListResponse: + """ + Handle request to retrieve all conversations for the authenticated user. + + ### Parameters: + - request: The incoming HTTP request (used by middleware). + - auth: Auth context tuple resolved from the authentication dependency. + + ### Returns: + - AgenticConversationListResponse: Metadata for conversations visible to the caller. + + ### Raises: + - HTTPException: + - 401: Unauthorized - Missing or invalid credentials + - 403: Forbidden - Insufficient permissions + - 500: Internal Server Error - Configuration not loaded or database failure + - 503: Service Unavailable - Kubernetes API unavailable when required by auth + """ + with tracer.start_as_current_span("conversations_v3.list") as span: + check_configuration_loaded(configuration) + user_id, _, _, _ = auth + others_allowed = ( + Action.LIST_OTHERS_CONVERSATIONS in request.state.authorized_actions + ) + logger.info("Retrieving conversations for user %s", user_id) + conversations = await run_in_threadpool( + list_conversations, user_id, others_allowed + ) + span.set_attribute("conversations.count", len(conversations)) + return AgenticConversationListResponse(conversations=conversations) + + +@router.get( + "/conversations/{conversation_id}", + responses=conversation_get_responses, +) +@authorize(Action.GET_CONVERSATION) +async def get_conversation_endpoint_handler( + request: Request, + conversation_id: str, + auth: Any = Depends(get_auth_dependency()), +) -> AgenticConversationGetResponse: + """ + Handle request to retrieve a conversation identified by its ID. + + Loads agent display history from persistence, including ordered agent turns. + + ### Parameters: + - request: The incoming HTTP request (used by middleware). + - conversation_id: Unique identifier of the conversation to retrieve. + - auth: Auth context tuple resolved from the authentication dependency. + + ### Returns: + - AgenticConversationGetResponse: Conversation metadata and agent turn history. + + ### Raises: + - HTTPException: + - 400: Bad Request - Invalid conversation ID format + - 401: Unauthorized - Missing or invalid credentials + - 403: Forbidden - Insufficient permissions to read this conversation + - 404: Not Found - Conversation does not exist + - 500: Internal Server Error - Configuration not loaded or database failure + - 503: Service Unavailable - Kubernetes API unavailable when required by auth + """ + with tracer.start_as_current_span("conversations_v3.get") as span: + check_configuration_loaded(configuration) + validate_conversation_id(conversation_id) + user_id, _, _, _ = auth + others_allowed = ( + Action.READ_OTHERS_CONVERSATIONS in request.state.authorized_actions + ) + logger.info("Retrieving conversation %s for user %s", conversation_id, user_id) + conversation = await run_in_threadpool( + get_conversation, conversation_id, user_id, others_allowed + ) + span.set_attribute("conversations.found", True) + span.set_attribute("conversations.turns.count", len(conversation.chat_history)) + return AgenticConversationGetResponse.model_validate(conversation) + + +@router.delete( + "/conversations/{conversation_id}", responses=conversation_delete_responses +) +@authorize(Action.DELETE_CONVERSATION) +async def delete_conversation_endpoint_handler( + request: Request, + conversation_id: str, + auth: Any = Depends(get_auth_dependency()), +) -> ConversationDeleteResponse: + """ + Handle request to delete a conversation by ID. + + ### Parameters: + - request: The incoming HTTP request (used by middleware). + - conversation_id: Unique identifier of the conversation to delete. + - auth: Auth context tuple resolved from the authentication dependency. + + ### Returns: + - ConversationDeleteResponse: Whether the conversation was deleted. + + ### Raises: + - HTTPException: + - 400: Bad Request - Invalid conversation ID format + - 401: Unauthorized - Missing or invalid credentials + - 403: Forbidden - Insufficient permissions to delete this conversation + - 500: Internal Server Error - Configuration not loaded or database failure + - 503: Service Unavailable - Kubernetes API unavailable when required by auth + """ + with tracer.start_as_current_span("conversations_v3.delete") as span: + check_configuration_loaded(configuration) + validate_conversation_id(conversation_id) + user_id, _, _, _ = auth + others_allowed = ( + Action.DELETE_OTHERS_CONVERSATIONS in request.state.authorized_actions + ) + logger.info("Deleting conversation %s for user %s", conversation_id, user_id) + deleted = await run_in_threadpool( + delete_conversation, conversation_id, user_id, others_allowed + ) + span.set_attribute("conversations.deleted", deleted) + return ConversationDeleteResponse( + deleted=deleted, conversation_id=conversation_id + ) + + +@router.put("/conversations/{conversation_id}", responses=conversation_update_responses) +@authorize(Action.UPDATE_CONVERSATION) +async def update_conversation_endpoint_handler( + request: Request, + conversation_id: str, + update_request: ConversationUpdateRequest, + auth: Any = Depends(get_auth_dependency()), +) -> ConversationUpdateResponse: + """ + Handle request to update a conversation topic summary by ID. + + ### Parameters: + - request: The incoming HTTP request (used by middleware). + - conversation_id: Unique identifier of the conversation to update. + - update_request: Request body containing the new topic summary. + - auth: Auth context tuple resolved from the authentication dependency. + + ### Returns: + - ConversationUpdateResponse: Result of the update operation. + + ### Raises: + - HTTPException: + - 400: Bad Request - Invalid conversation ID format + - 401: Unauthorized - Missing or invalid credentials + - 403: Forbidden - Insufficient permissions to update this conversation + - 404: Not Found - Conversation does not exist + - 500: Internal Server Error - Configuration not loaded or database failure + - 503: Service Unavailable - Kubernetes API unavailable when required by auth + """ + with tracer.start_as_current_span("conversations_v3.update") as span: + check_configuration_loaded(configuration) + validate_conversation_id(conversation_id) + user_id, _, _, _ = auth + others_allowed = ( + Action.QUERY_OTHERS_CONVERSATIONS in request.state.authorized_actions + ) + logger.info( + "Updating topic summary for conversation %s for user %s", + conversation_id, + user_id, + ) + result = await run_in_threadpool( + update_conversation_topic, + conversation_id, + user_id, + others_allowed, + update_request.topic_summary, + ) + span.set_attribute("conversations.updated", result) + return ConversationUpdateResponse( + conversation_id=conversation_id, + success=result, + ) diff --git a/src/app/main.py b/src/app/main.py index c4c4479ee3..bc08c7e2de 100644 --- a/src/app/main.py +++ b/src/app/main.py @@ -46,6 +46,7 @@ {"name": "authorized", "description": "Authorization probe."}, {"name": "config", "description": "Service configuration."}, {"name": "conversations_v2", "description": "Conversations API v2."}, + {"name": "conversations_v3", "description": "Conversations API v3."}, {"name": "feedback", "description": "User feedback."}, {"name": "health", "description": "Health and readiness probes."}, {"name": "info", "description": "Service information."}, diff --git a/src/app/routers.py b/src/app/routers.py index bf319b8b0f..f6bfbe481e 100644 --- a/src/app/routers.py +++ b/src/app/routers.py @@ -8,6 +8,7 @@ authorized, config, conversations_v2, + conversations_v3, feedback, health, info, @@ -39,8 +40,9 @@ def include_routers(app: FastAPI) -> None: Register and mount project routers on the given FastAPI application. Registers endpoint routers and assigns URL prefixes: most endpoints are - mounted under "/v1", v2 routers under "/v2", and core endpoints (health, - authorized, metrics) are mounted without a version prefix. + mounted under "/v1", v2 routers under "/v2", v3 routers under "/v3", and + core endpoints (health, authorized, metrics) are mounted without a version + prefix. Parameters: ---------- @@ -67,6 +69,7 @@ def include_routers(app: FastAPI) -> None: app.include_router(saved_prompts.router, prefix="/v1") app.include_router(feedback.router, prefix="/v1") app.include_router(conversations_v2.router, prefix="/v2") + app.include_router(conversations_v3.router, prefix="/v3") app.include_router(responses.router, prefix="/v1") # RHEL Lightspeed rlsapi v1 compatibility - stateless CLA (Command Line Assistant) endpoint app.include_router(rlsapi_v1.router, prefix="/v1") diff --git a/src/conversations/display_history/persistence/facade/conversation.py b/src/conversations/display_history/persistence/facade/conversation.py index f647fdb08f..a9bf1c2733 100644 --- a/src/conversations/display_history/persistence/facade/conversation.py +++ b/src/conversations/display_history/persistence/facade/conversation.py @@ -138,7 +138,7 @@ def update_conversation_topic( user_id: str, others_allowed: bool, topic_summary: str, -) -> None: +) -> bool: """Update the conversation topic summary. Args: @@ -147,17 +147,22 @@ def update_conversation_topic( others_allowed: When true, allow updating other users' conversations. topic_summary: New topic summary text. + Returns: + True when the row was updated. + Raises: ConversationAccessDeniedError: Caller may not update this conversation. ConversationNotFoundError: Conversation does not exist. - DisplayHistoryDatabaseError: Database operation failed. + ConversationHistoryDatabaseError: Database operation failed. """ normalized = normalize_conversation_id(conversation_id) get_user_conversation(normalized, user_id, others_allowed) - update_conversation_topic_summary(normalized, topic_summary) + updated = update_conversation_topic_summary(normalized, topic_summary) logger.info( - "Updated topic summary for conversation %s for user %s", + "Updated topic summary for conversation %s for user %s: %s", normalized, user_id, + updated, ) + return updated diff --git a/src/models/api/responses/error/internal.py b/src/models/api/responses/error/internal.py index 747eb4888f..fe2c7a0958 100644 --- a/src/models/api/responses/error/internal.py +++ b/src/models/api/responses/error/internal.py @@ -59,6 +59,13 @@ class InternalServerErrorResponse(AbstractErrorResponse): "cause": "Failed to query the database", }, }, + { + "label": "database operation", + "detail": { + "response": "Database query failed", + "cause": "Failed to list conversations due to a database error.", + }, + }, { "label": "cluster version not found", "detail": { diff --git a/src/models/api/responses/successful/conversations.py b/src/models/api/responses/successful/conversations.py index cfc5a90be0..8a1b5c8f16 100644 --- a/src/models/api/responses/successful/conversations.py +++ b/src/models/api/responses/successful/conversations.py @@ -293,7 +293,7 @@ class ConversationUpdateResponse(AbstractSuccessfulResponse): Attributes: conversation_id: The conversation ID (UUID) that was updated. success: Whether the update was successful. - message: A message about the update result. + message: Human-readable outcome derived from ``success``. """ @@ -307,11 +307,15 @@ class ConversationUpdateResponse(AbstractSuccessfulResponse): description="Whether the update was successful", examples=[True], ) - message: str = Field( - ..., - description="A message about the update result", - examples=["Topic summary updated successfully"], - ) + + @computed_field + def message(self) -> str: + """Outcome message for the topic summary update.""" + return ( + "Topic summary updated successfully" + if self.success + else "Topic summary was not updated" + ) model_config = { "json_schema_extra": { diff --git a/tests/integration/test_openapi_json.py b/tests/integration/test_openapi_json.py index d76d900ac2..5468768fb6 100644 --- a/tests/integration/test_openapi_json.py +++ b/tests/integration/test_openapi_json.py @@ -291,6 +291,22 @@ def test_servers_section_present_from_url(spec_from_url: dict[str, Any]) -> None "put", {"200", "400", "401", "403", "404", "500"}, ), + ("/v3/conversations", "get", {"200", "401", "403", "500"}), + ( + "/v3/conversations/{conversation_id}", + "get", + {"200", "400", "401", "403", "404", "500"}, + ), + ( + "/v3/conversations/{conversation_id}", + "delete", + {"200", "400", "401", "403", "500"}, + ), + ( + "/v3/conversations/{conversation_id}", + "put", + {"200", "400", "401", "403", "404", "500"}, + ), ("/readiness", "get", {"200", "401", "403", "503"}), ("/liveness", "get", {"200", "401", "403"}), ("/authorized", "post", {"200", "401", "403"}), @@ -392,6 +408,22 @@ def test_paths_and_responses_exist_from_file( "put", {"200", "400", "401", "403", "404", "500"}, ), + ("/v3/conversations", "get", {"200", "401", "403", "500"}), + ( + "/v3/conversations/{conversation_id}", + "get", + {"200", "400", "401", "403", "404", "500"}, + ), + ( + "/v3/conversations/{conversation_id}", + "delete", + {"200", "400", "401", "403", "500"}, + ), + ( + "/v3/conversations/{conversation_id}", + "put", + {"200", "400", "401", "403", "404", "500"}, + ), ("/readiness", "get", {"200", "401", "403", "503"}), ("/liveness", "get", {"200", "401", "403"}), ("/authorized", "post", {"200", "401", "403"}), diff --git a/tests/unit/app/endpoints/README.md b/tests/unit/app/endpoints/README.md index 3d0a101c28..120bbf98b6 100644 --- a/tests/unit/app/endpoints/README.md +++ b/tests/unit/app/endpoints/README.md @@ -32,6 +32,10 @@ Unit tests for the /conversations REST API endpoints. Unit tests for the /conversations REST API endpoints. +## [test_conversations_v3.py](test_conversations_v3.py) + +Unit tests for the /v3/conversations REST API endpoints. + ## [test_feedback.py](test_feedback.py) Unit tests for the /feedback REST API endpoint. diff --git a/tests/unit/app/endpoints/test_conversations_v2.py b/tests/unit/app/endpoints/test_conversations_v2.py index fdfab1e04f..f3a49a5395 100644 --- a/tests/unit/app/endpoints/test_conversations_v2.py +++ b/tests/unit/app/endpoints/test_conversations_v2.py @@ -985,7 +985,7 @@ async def test_successful_update( assert isinstance(response, ConversationUpdateResponse) assert response.conversation_id == VALID_CONVERSATION_ID assert response.success is True - assert response.message == "Topic summary updated successfully" + assert response.model_dump()["message"] == "Topic summary updated successfully" # Verify that set_topic_summary was called mock_configuration.conversation_cache.set_topic_summary.assert_called_once_with( diff --git a/tests/unit/app/endpoints/test_conversations_v3.py b/tests/unit/app/endpoints/test_conversations_v3.py new file mode 100644 index 0000000000..110009f179 --- /dev/null +++ b/tests/unit/app/endpoints/test_conversations_v3.py @@ -0,0 +1,266 @@ +"""Unit tests for the /v3/conversations REST API endpoints.""" + +from datetime import UTC, datetime + +import pytest +from fastapi import Request +from pytest_mock import MockerFixture + +from app.endpoints.conversations_v3 import ( + delete_conversation_endpoint_handler, + get_conversation_endpoint_handler, + get_conversations_list_endpoint_handler, + update_conversation_endpoint_handler, +) +from conversations.display_history.agentic.models.conversation import ( + Conversation, + ConversationMetadata, +) +from conversations.display_history.errors import InvalidConversationIdError +from models.api.requests import ConversationUpdateRequest +from models.config import Action +from tests.unit.utils.auth_helpers import mock_authorization_resolvers + +MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token") +VALID_CONVERSATION_ID = "123e4567-e89b-12d3-a456-426614174000" +INVALID_CONVERSATION_ID = "invalid-id" + + +@pytest.fixture(name="dummy_request") +def dummy_request_fixture() -> Request: + """Mock request object for testing. + + The returned Request has state.authorized_actions set to every Action. + """ + request = Request(scope={"type": "http"}) + request.state.authorized_actions = set(Action) + return request + + +@pytest.fixture(name="configure_v3") +def configure_v3_fixture(mocker: MockerFixture) -> None: + """Authorize the request and skip configuration loading.""" + mock_authorization_resolvers(mocker) + mocker.patch("app.endpoints.conversations_v3.check_configuration_loaded") + + +def sample_metadata() -> ConversationMetadata: + """Conversation metadata used by list endpoint tests.""" + return ConversationMetadata( + conversation_id=VALID_CONVERSATION_ID, + created_at=datetime(2024, 1, 1, tzinfo=UTC), + topic_summary="summary", + ) + + +def sample_conversation() -> Conversation: + """Conversation used by get endpoint tests.""" + return Conversation( + conversation_id=VALID_CONVERSATION_ID, + created_at=datetime(2024, 1, 1, tzinfo=UTC), + topic_summary="summary", + chat_history=[], + ) + + +@pytest.mark.usefixtures("configure_v3") +class TestGetConversationsListEndpoint: + """Test cases for the GET /v3/conversations endpoint.""" + + @pytest.mark.asyncio + async def test_successful_retrieval( + self, mocker: MockerFixture, dummy_request: Request + ) -> None: + """Test successful retrieval of the conversation list.""" + mocker.patch( + "app.endpoints.conversations_v3.list_conversations", + return_value=[sample_metadata()], + ) + + response = await get_conversations_list_endpoint_handler( + request=dummy_request, + auth=MOCK_AUTH, + ) + + assert len(response.conversations) == 1 + assert response.conversations[0].conversation_id == VALID_CONVERSATION_ID + + @pytest.mark.asyncio + async def test_successful_retrieval_empty_list( + self, mocker: MockerFixture, dummy_request: Request + ) -> None: + """Test successful retrieval of an empty conversation list.""" + mocker.patch( + "app.endpoints.conversations_v3.list_conversations", + return_value=[], + ) + + response = await get_conversations_list_endpoint_handler( + request=dummy_request, + auth=MOCK_AUTH, + ) + + assert response.conversations == [] + + +@pytest.mark.usefixtures("configure_v3") +class TestGetConversationEndpoint: + """Test cases for the GET /v3/conversations/{conversation_id} endpoint.""" + + @pytest.mark.asyncio + async def test_successful_retrieval( + self, mocker: MockerFixture, dummy_request: Request + ) -> None: + """Test successful retrieval of a conversation.""" + mocker.patch( + "app.endpoints.conversations_v3.get_conversation", + return_value=sample_conversation(), + ) + + response = await get_conversation_endpoint_handler( + request=dummy_request, + conversation_id=VALID_CONVERSATION_ID, + auth=MOCK_AUTH, + ) + + assert response.conversation_id == VALID_CONVERSATION_ID + assert response.chat_history == [] + + @pytest.mark.asyncio + async def test_invalid_conversation_id_format( + self, mocker: MockerFixture, dummy_request: Request + ) -> None: + """Test the endpoint with an invalid conversation ID format.""" + get_mock = mocker.patch("app.endpoints.conversations_v3.get_conversation") + + with pytest.raises(InvalidConversationIdError): + await get_conversation_endpoint_handler( + request=dummy_request, + conversation_id=INVALID_CONVERSATION_ID, + auth=MOCK_AUTH, + ) + + get_mock.assert_not_called() + + +@pytest.mark.usefixtures("configure_v3") +class TestDeleteConversationEndpoint: + """Test cases for the DELETE /v3/conversations/{conversation_id} endpoint.""" + + @pytest.mark.asyncio + async def test_successful_deletion( + self, mocker: MockerFixture, dummy_request: Request + ) -> None: + """Test successful deletion of a conversation.""" + mocker.patch( + "app.endpoints.conversations_v3.delete_conversation", + return_value=True, + ) + + response = await delete_conversation_endpoint_handler( + request=dummy_request, + conversation_id=VALID_CONVERSATION_ID, + auth=MOCK_AUTH, + ) + + assert response.deleted is True + assert response.conversation_id == VALID_CONVERSATION_ID + + @pytest.mark.asyncio + async def test_conversation_not_deleted( + self, mocker: MockerFixture, dummy_request: Request + ) -> None: + """Test deletion when the conversation is already missing.""" + mocker.patch( + "app.endpoints.conversations_v3.delete_conversation", + return_value=False, + ) + + response = await delete_conversation_endpoint_handler( + request=dummy_request, + conversation_id=VALID_CONVERSATION_ID, + auth=MOCK_AUTH, + ) + + assert response.deleted is False + + @pytest.mark.asyncio + async def test_invalid_conversation_id_format( + self, mocker: MockerFixture, dummy_request: Request + ) -> None: + """Test the endpoint with an invalid conversation ID format.""" + delete_mock = mocker.patch("app.endpoints.conversations_v3.delete_conversation") + + with pytest.raises(InvalidConversationIdError): + await delete_conversation_endpoint_handler( + request=dummy_request, + conversation_id=INVALID_CONVERSATION_ID, + auth=MOCK_AUTH, + ) + + delete_mock.assert_not_called() + + +@pytest.mark.usefixtures("configure_v3") +class TestUpdateConversationEndpoint: + """Test cases for the PUT /v3/conversations/{conversation_id} endpoint.""" + + @pytest.mark.asyncio + async def test_successful_update( + self, mocker: MockerFixture, dummy_request: Request + ) -> None: + """Test successful update of a conversation topic summary.""" + mocker.patch( + "app.endpoints.conversations_v3.update_conversation_topic", + return_value=True, + ) + + response = await update_conversation_endpoint_handler( + request=dummy_request, + conversation_id=VALID_CONVERSATION_ID, + update_request=ConversationUpdateRequest(topic_summary="new topic"), + auth=MOCK_AUTH, + ) + + assert response.success is True + assert response.conversation_id == VALID_CONVERSATION_ID + assert response.model_dump()["message"] == "Topic summary updated successfully" + + @pytest.mark.asyncio + async def test_conversation_not_updated( + self, mocker: MockerFixture, dummy_request: Request + ) -> None: + """Test update when the conversation row disappears before the update.""" + mocker.patch( + "app.endpoints.conversations_v3.update_conversation_topic", + return_value=False, + ) + + response = await update_conversation_endpoint_handler( + request=dummy_request, + conversation_id=VALID_CONVERSATION_ID, + update_request=ConversationUpdateRequest(topic_summary="new topic"), + auth=MOCK_AUTH, + ) + + assert response.success is False + assert response.model_dump()["message"] == "Topic summary was not updated" + + @pytest.mark.asyncio + async def test_invalid_conversation_id_format( + self, mocker: MockerFixture, dummy_request: Request + ) -> None: + """Test the endpoint with an invalid conversation ID format.""" + update_mock = mocker.patch( + "app.endpoints.conversations_v3.update_conversation_topic" + ) + + with pytest.raises(InvalidConversationIdError): + await update_conversation_endpoint_handler( + request=dummy_request, + conversation_id=INVALID_CONVERSATION_ID, + update_request=ConversationUpdateRequest(topic_summary="new topic"), + auth=MOCK_AUTH, + ) + + update_mock.assert_not_called() diff --git a/tests/unit/app/test_routers.py b/tests/unit/app/test_routers.py index ea01759224..78423adc3a 100644 --- a/tests/unit/app/test_routers.py +++ b/tests/unit/app/test_routers.py @@ -13,6 +13,7 @@ authorized, config, conversations_v2, + conversations_v3, feedback, health, info, @@ -52,7 +53,7 @@ def __init__(self) -> None: # pylint: disable=super-init-not-called """ self.routers: list[tuple[Any, Optional[str]]] = [] - def include_router( # pylint: disable=too-many-arguments + def include_router( # pylint: disable=too-many-arguments,arguments-differ self, router: Any, *, @@ -126,7 +127,7 @@ def test_include_routers() -> None: include_routers(app) # are all routers added? - assert len(app.routers) == 24 + assert len(app.routers) == 25 assert root.router in app.get_routers() assert info.router in app.get_routers() assert models.router in app.get_routers() @@ -136,6 +137,7 @@ def test_include_routers() -> None: assert shields.router in app.get_routers() assert skills.router in app.get_routers() assert prompts.router in app.get_routers() + assert rags.router in app.get_routers() assert saved_prompts.router in app.get_routers() assert query.router in app.get_routers() assert streaming_query.router in app.get_routers() @@ -145,6 +147,7 @@ def test_include_routers() -> None: assert authorized.router in app.get_routers() # assert conversations.router in app.get_routers() assert conversations_v2.router in app.get_routers() + assert conversations_v3.router in app.get_routers() assert metrics.router in app.get_routers() assert rlsapi_v1.router in app.get_routers() assert a2a.router in app.get_routers() @@ -161,13 +164,13 @@ def test_check_prefixes() -> None: Asserts that 25 routers are registered on a MockFastAPI instance and that each router's prefix matches the expected value (e.g., root, health, authorized, metrics use an empty prefix; most API routers use "/v1"; - conversations_v2 uses "/v2"). + conversations_v2 uses "/v2"; conversations_v3 uses "/v3"). """ app = MockFastAPI() include_routers(app) # are all routers added? - assert len(app.routers) == 24 + assert len(app.routers) == 25 assert app.get_router_prefix(root.router) == "" assert app.get_router_prefix(info.router) == "/v1" assert app.get_router_prefix(models.router) == "/v1" @@ -187,6 +190,7 @@ def test_check_prefixes() -> None: assert app.get_router_prefix(authorized.router) == "" # assert app.get_router_prefix(conversations.router) == "/v1" assert app.get_router_prefix(conversations_v2.router) == "/v2" + assert app.get_router_prefix(conversations_v3.router) == "/v3" assert app.get_router_prefix(metrics.router) == "" assert app.get_router_prefix(rlsapi_v1.router) == "/v1" assert app.get_router_prefix(a2a.router) == "" diff --git a/tests/unit/conversations/display_history/persistence/facade/test_conversation.py b/tests/unit/conversations/display_history/persistence/facade/test_conversation.py index 6475a0d71e..2d0ef267a3 100644 --- a/tests/unit/conversations/display_history/persistence/facade/test_conversation.py +++ b/tests/unit/conversations/display_history/persistence/facade/test_conversation.py @@ -175,11 +175,14 @@ def test_update_conversation_topic(memory_engine: Engine) -> None: """Owners can replace the topic summary.""" with Session(memory_engine) as session: seed_sample_conversation_and_turn(session) - update_conversation_topic( - TEST_CONVERSATION_ID, - TEST_USER_ID, - False, - "Updated topic", + assert ( + update_conversation_topic( + TEST_CONVERSATION_ID, + TEST_USER_ID, + False, + "Updated topic", + ) + is True ) loaded = get_conversation_by_id(TEST_CONVERSATION_ID) assert loaded is not None diff --git a/tests/unit/models/responses/test_error_responses.py b/tests/unit/models/responses/test_error_responses.py index 5b564092af..ec1f9d8cf5 100644 --- a/tests/unit/models/responses/test_error_responses.py +++ b/tests/unit/models/responses/test_error_responses.py @@ -684,7 +684,7 @@ def test_openapi_response(self) -> None: # Verify example count matches schema examples count assert len(examples) == expected_count - assert expected_count == 10 + assert expected_count == 11 # Verify all labeled examples are present assert "internal" in examples @@ -694,6 +694,7 @@ def test_openapi_response(self) -> None: assert "query" in examples assert "conversation cache" in examples assert "database" in examples + assert "database operation" in examples assert "cluster version not found" in examples assert "cluster version permission denied" in examples assert "invalid cluster version" in examples diff --git a/tests/unit/models/responses/test_successful_responses.py b/tests/unit/models/responses/test_successful_responses.py index 3dd158ec98..0e0242bb04 100644 --- a/tests/unit/models/responses/test_successful_responses.py +++ b/tests/unit/models/responses/test_successful_responses.py @@ -1026,20 +1026,17 @@ def test_constructor_success(self) -> None: response = ConversationUpdateResponse( conversation_id="123e4567-e89b-12d3-a456-426614174000", success=True, - message="Topic summary updated successfully", ) assert isinstance(response, AbstractSuccessfulResponse) assert response.conversation_id == "123e4567-e89b-12d3-a456-426614174000" assert response.success is True - assert response.message == "Topic summary updated successfully" + assert response.model_dump()["message"] == "Topic summary updated successfully" def test_constructor_failure(self) -> None: """Test ConversationUpdateResponse with failed update.""" - response = ConversationUpdateResponse( - conversation_id="conv-123", success=False, message="Update failed" - ) + response = ConversationUpdateResponse(conversation_id="conv-123", success=False) assert response.success is False - assert response.message == "Update failed" + assert response.model_dump()["message"] == "Topic summary was not updated" def test_missing_required_parameters(self) -> None: """Test ConversationUpdateResponse raises ValidationError when required fields missing.""" diff --git a/tests/unit/utils/dumpers/test_models_dumper.py b/tests/unit/utils/dumpers/test_models_dumper.py index da57323973..2b40463c9d 100644 --- a/tests/unit/utils/dumpers/test_models_dumper.py +++ b/tests/unit/utils/dumpers/test_models_dumper.py @@ -2659,6 +2659,13 @@ def test_dump_models(tmpdir: Path) -> None: }, "label": "database" }, + { + "detail": { + "cause": "Failed to list conversations due to a database error.", + "response": "Database query failed" + }, + "label": "database operation" + }, { "detail": { "cause": "ClusterVersion 'version' resource not found in OpenShift cluster",