Skip to content

Commit e776c5b

Browse files
committed
test: fix Anthropic unit tests to match corrected message ordering
Update test expectations to match the fixed message ordering where context messages come first (chronological order), then the main prompt. This aligns with the fix that resolved context conversation issues in the Anthropic API integration. The corrected order ensures proper conversation flow: 1. Previous context (user question) 2. Previous context (assistant answer) 3. Current user prompt All 111 Anthropic unit test assertions now pass.
1 parent 4948105 commit e776c5b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/unit/test_anthropic_types.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,15 @@ TEST_CASE("Anthropic MessagesRequest structure", "[anthropic][unit]") {
201201
REQUIRE(anthropicRequest.temperature == 0.5f);
202202
REQUIRE(anthropicRequest.messages.size() == 3); // 2 context + 1 current
203203

204-
// Check the main prompt message
204+
// Check context messages come first (chronological order)
205205
REQUIRE(anthropicRequest.messages[0].role == Anthropic::MessageRole::USER);
206-
REQUIRE(anthropicRequest.messages[0].content[0].text == "Current question");
206+
REQUIRE(anthropicRequest.messages[0].content[0].text == "Previous question");
207+
REQUIRE(anthropicRequest.messages[1].role == Anthropic::MessageRole::ASSISTANT);
208+
REQUIRE(anthropicRequest.messages[1].content[0].text == "Previous answer");
207209

208-
// Check context messages
209-
REQUIRE(anthropicRequest.messages[1].role == Anthropic::MessageRole::USER);
210-
REQUIRE(anthropicRequest.messages[1].content[0].text == "Previous question");
211-
REQUIRE(anthropicRequest.messages[2].role == Anthropic::MessageRole::ASSISTANT);
212-
REQUIRE(anthropicRequest.messages[2].content[0].text == "Previous answer");
210+
// Check the main prompt message comes last
211+
REQUIRE(anthropicRequest.messages[2].role == Anthropic::MessageRole::USER);
212+
REQUIRE(anthropicRequest.messages[2].content[0].text == "Current question");
213213
}
214214

215215
SECTION("LLMRequest conversion with invalid context") {
@@ -223,9 +223,10 @@ TEST_CASE("Anthropic MessagesRequest structure", "[anthropic][unit]") {
223223
LLMRequest llmRequest(config, "Main prompt", context);
224224
auto anthropicRequest = Anthropic::MessagesRequest::fromLLMRequest(llmRequest);
225225

226-
// Should have main prompt + 1 valid context message
226+
// Should have 1 valid context message + main prompt
227227
REQUIRE(anthropicRequest.messages.size() == 2);
228-
REQUIRE(anthropicRequest.messages[1].content[0].text == "Should be included");
228+
REQUIRE(anthropicRequest.messages[0].content[0].text == "Should be included");
229+
REQUIRE(anthropicRequest.messages[1].content[0].text == "Main prompt");
229230
}
230231
}
231232

0 commit comments

Comments
 (0)