diff --git a/backend/internal/service/gateway_thinking_filter_precheck_test.go b/backend/internal/service/gateway_thinking_filter_precheck_test.go index b7cb36c4d9..639894e48b 100644 --- a/backend/internal/service/gateway_thinking_filter_precheck_test.go +++ b/backend/internal/service/gateway_thinking_filter_precheck_test.go @@ -3,6 +3,8 @@ package service import ( "bytes" "encoding/json" + "os" + "os/exec" "strings" "testing" @@ -75,6 +77,21 @@ func signedThinkingHistoryBody() []byte { } func TestFilterThinkingBlocksSignedHistorySkipsDecode(t *testing.T) { + // AllocsPerRun reads process-wide counters. Background workers from other + // service tests can otherwise make unchanged signed history fail this check. + const isolatedEnv = "SUB2API_TEST_SIGNED_HISTORY_ALLOCS" + if os.Getenv(isolatedEnv) != "1" { + binary, err := os.Executable() + require.NoError(t, err) + cmd := exec.CommandContext(t.Context(), binary, + "-test.run=^TestFilterThinkingBlocksSignedHistorySkipsDecode$", + "-test.count=1", "-test.timeout=30s") + cmd.Env = append(os.Environ(), isolatedEnv+"=1") + output, err := cmd.CombinedOutput() + require.NoError(t, err, "%s", output) + return + } + body := signedThinkingHistoryBody() allocs := testing.AllocsPerRun(5, func() { got := filterThinkingBlocksInternal(body, false)