From 1a8a153c56cbecd8c0cd81c0e9832700c69d6ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Banaszewski?= Date: Mon, 25 May 2026 16:41:55 +0200 Subject: [PATCH] chore: fix flake in TestResponsesInjectedTool (#25630) Fixes flake in TestResponsesInjectedTool. See https://github.com/coder/coder/pull/25630/changes/d9bfeb20092129127ad5e7958c5b8dbf46740527 for reproduction. Due to AsyncRecorded token usages may be recorded in different order then expected. Fixes: https://github.com/coder/internal/issues/1544 --- .../internal/integrationtest/responses_internal_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aibridge/internal/integrationtest/responses_internal_test.go b/aibridge/internal/integrationtest/responses_internal_test.go index 073483c8e8..906f817500 100644 --- a/aibridge/internal/integrationtest/responses_internal_test.go +++ b/aibridge/internal/integrationtest/responses_internal_test.go @@ -920,7 +920,12 @@ func TestResponsesInjectedTool(t *testing.T) { for i := range tokenUsages { tokenUsages[i].InterceptionID = "" // ignore interception ID and time creation when comparing tokenUsages[i].CreatedAt = time.Time{} - require.Equal(t, tc.expectTokenUsages[i], *tokenUsages[i]) + } + + // Match by content, not position, AsyncRecorder may flake. + // See https://github.com/coder/internal/issues/1544. + for _, expected := range tc.expectTokenUsages { + require.Contains(t, tokenUsages, &expected) } // Verify the response is the final tool response (after agentic loop).