Skip to content

Commit 3a77581

Browse files
[8.x] [obs AI Assistant] fix title_conversation failing test (elastic#216112) (elastic#216511)
# Backport This will backport the following commits from `main` to `8.x`: - [[obs AI Assistant] fix title_conversation failing test (elastic#216112)](elastic#216112) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Arturo Lidueña","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-03-31T14:56:32Z","message":"[obs AI Assistant] fix title_conversation failing test (elastic#216112)\n\nCloses elastic#215952\n\n[obs AI Assistant] fix title_conversation failing test","sha":"3c9593b1a62aaa34922f27b2689699f2e545f37f","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Obs AI Assistant","backport:version","v9.1.0","v8.19.0"],"title":"[obs AI Assistant] fix title_conversation failing test","number":216112,"url":"https://github.com/elastic/kibana/pull/216112","mergeCommit":{"message":"[obs AI Assistant] fix title_conversation failing test (elastic#216112)\n\nCloses elastic#215952\n\n[obs AI Assistant] fix title_conversation failing test","sha":"3c9593b1a62aaa34922f27b2689699f2e545f37f"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216112","number":216112,"mergeCommit":{"message":"[obs AI Assistant] fix title_conversation failing test (elastic#216112)\n\nCloses elastic#215952\n\n[obs AI Assistant] fix title_conversation failing test","sha":"3c9593b1a62aaa34922f27b2689699f2e545f37f"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
1 parent d8dd5d0 commit 3a77581

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

x-pack/test/api_integration/deployment_agnostic/apis/observability/ai_assistant/complete/functions/title_conversation.spec.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@ import {
1111
TITLE_CONVERSATION_FUNCTION_NAME,
1212
TITLE_SYSTEM_MESSAGE,
1313
} from '@kbn/observability-ai-assistant-plugin/server/service/client/operators/get_generated_title';
14+
import { MessageRole } from '@kbn/observability-ai-assistant-plugin/common';
1415
import {
1516
LlmProxy,
1617
createLlmProxy,
1718
} from '../../../../../../../observability_ai_assistant_api_integration/common/create_llm_proxy';
18-
import { chatComplete } from '../../utils/conversation';
19+
import { chatComplete, clearConversations } from '../../utils/conversation';
1920
import type { DeploymentAgnosticFtrProviderContext } from '../../../../../ftr_provider_context';
2021

2122
export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderContext) {
2223
const log = getService('log');
2324
const observabilityAIAssistantAPIClient = getService('observabilityAIAssistantApi');
25+
const es = getService('es');
2426

25-
// Failing: See https://github.com/elastic/kibana/issues/215952
26-
describe.skip('when calling the title_conversation function', function () {
27+
describe('when calling the title_conversation function', function () {
2728
// Fails on MKI: https://github.com/elastic/kibana/issues/205581
2829
this.tags(['failsOnMKI']);
2930
let llmProxy: LlmProxy;
@@ -51,7 +52,8 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
5152
let conversationId: string;
5253

5354
before(async () => {
54-
void llmProxy.interceptTitle(TITLE);
55+
await clearConversations(es);
56+
const simulatorPromise = llmProxy.interceptTitle(TITLE);
5557
void llmProxy.interceptConversation('The sky is blue because of Rayleigh scattering.');
5658

5759
const res = await chatComplete({
@@ -64,7 +66,12 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
6466

6567
await llmProxy.waitForAllInterceptorsToHaveBeenCalled();
6668

67-
titleRequestBody = llmProxy.interceptedRequests[0].requestBody;
69+
const simulator = await simulatorPromise;
70+
titleRequestBody = simulator.requestBody;
71+
});
72+
73+
after(async () => {
74+
await clearConversations(es);
6875
});
6976

7077
it('makes 2 requests to the LLM', () => {
@@ -73,13 +80,13 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon
7380

7481
it('sends the correct system message to the LLM for the title', () => {
7582
expect(
76-
titleRequestBody.messages.find((message) => message.role === 'system')?.content
83+
titleRequestBody.messages.find((message) => message.role === MessageRole.System)?.content
7784
).to.be(TITLE_SYSTEM_MESSAGE);
7885
});
7986

8087
it('sends the correct user message to the LLM for the title', () => {
8188
expect(
82-
titleRequestBody.messages.find((message) => message.role === 'user')?.content
89+
titleRequestBody.messages.find((message) => message.role === MessageRole.User)?.content
8390
).to.contain('Why the sky is blue?');
8491
});
8592

0 commit comments

Comments
 (0)